-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy path12
More file actions
36 lines (30 loc) · 1010 Bytes
/
12
File metadata and controls
36 lines (30 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class Solution {
public:
bool stringStack(string &pat, string &tar) {
// code here
int n= pat.size();
int m= tar.size();
int i=n-1;
int j=m-1;
int count =0;
while (i>=0 && j>=0){
if (pat[i]==tar[j]){
if (count%2==0) {
j--;
count=0;
i--;
}
else{
i--;
count++;
}
}
else{
i--;
count++;
}
}
if (j<0) return true;
else return false;
}
};