Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 13a6ee2

Browse files
authored
Create 12
1 parent 4915e78 commit 13a6ee2

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

12

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
class Solution {
2+
public:
3+
bool stringStack(string &pat, string &tar) {
4+
// code here
5+
int n= pat.size();
6+
int m= tar.size();
7+
8+
int i=n-1;
9+
int j=m-1;
10+
int count =0;
11+
while (i>=0 && j>=0){
12+
13+
if (pat[i]==tar[j]){
14+
if (count%2==0) {
15+
j--;
16+
count=0;
17+
i--;
18+
}
19+
else{
20+
i--;
21+
count++;
22+
23+
}
24+
25+
}
26+
27+
else{
28+
i--;
29+
count++;
30+
}
31+
}
32+
if (j<0) return true;
33+
else return false;
34+
}
35+
};
36+

0 commit comments

Comments
 (0)