leetcode new problems

This commit is contained in:
2026-02-11 14:48:41 +05:30
parent 192ce44a81
commit 0f52d46c67
29 changed files with 658 additions and 5 deletions
+15
View File
@@ -0,0 +1,15 @@
class Solution{
public:
int strStr(string haystack, string needle){
if(needle.length() > haystack.length()) return -1;
for(int i =0;i <= haystack.length() - needle.length();i++){
if(haystack.substr(i, needle.length()) == needle)
return i;
}
return -1;
}
};
// TC : O(n*m)
// SC : O(m)
// m-> needle.length(), n-> haystack.length()
+11
View File
@@ -0,0 +1,11 @@
class Solution{
public :
int strStr(string haystack, string needle){
if(needle.empty()) return 0;
int n = haystack.length(), m = needle.length();
for(int i =0;i<=n-m; i++){
}
}
}