Skip to content

Commit 60c7cb3

Browse files
Create 1967. Number of Strings That Appear as Substrings in Word.cpp
1 parent 53e39c5 commit 60c7cb3

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
class Solution {
2+
public:
3+
bool issub(string temp, string word){
4+
int n = temp.size(), m = word.size();
5+
if(n > m) return false;
6+
7+
for(int i = 0 ; i < m-n+1 ; i++){
8+
string temp1 = word.substr(i,n);
9+
if(temp1 == temp ){
10+
return true;
11+
}
12+
}
13+
return false;
14+
}
15+
16+
int numOfStrings(vector<string>& patterns, string word) {
17+
int n = patterns.size();
18+
int i = 0, cnt = 0;
19+
20+
while(i < n){
21+
if(issub(patterns[i],word)){
22+
cnt++;
23+
}
24+
i++;
25+
}
26+
return cnt;
27+
}
28+
};

0 commit comments

Comments
 (0)