Initial commit

This commit is contained in:
Arkaprabha Chakraborty
2022-07-26 16:15:18 +05:30
commit cef4c4dcc4
65 changed files with 1806 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
#include <string>
class Solution {
public:
int strStr(std::string haystack, std::string needle) {
for (int i = 0; i < haystack.size(); ++i) {
if (haystack.at(i) == needle.at(0)) {
bool found = false;
for (int j = 0; i + j < haystack.size() && j < needle.size(); ++j) {
if (haystack.at(i + j) != needle.at(j)) {
break;
} else if (j == needle.size() - 1) {
found = true;
}
}
if (found) {
return i;
}
}
}
return -1;
}
};