Skip to content

Commit

Permalink
adding fourth sol (#86)
Browse files Browse the repository at this point in the history
LGTM 💯
  • Loading branch information
ayshachakure authored Oct 1, 2023
1 parent 3bcfc6e commit c201198
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution {
public:
int strStr(string haystack, string needle) {
const int m = haystack.length();
const int n = needle.length();

for (int i = 0; i < m - n + 1; i++)
if (haystack.substr(i, n) == needle)
return i;

return -1;
}
};

0 comments on commit c201198

Please sign in to comment.