mirror of
https://github.com/20kaushik02/leetcode-gulag.git
synced 2025-12-06 11:34:07 +00:00
18 lines
306 B
C++
18 lines
306 B
C++
#include "soln.hpp"
|
|
|
|
int Solution::strStr(string haystack, string needle)
|
|
{
|
|
int index = haystack.find(needle);
|
|
if (index != std::string::npos)
|
|
{
|
|
return index;
|
|
}
|
|
else
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
bool Solution::test(string haystack, string needle, int answer) {
|
|
return strStr(haystack, needle) == answer;
|
|
} |