We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8da19f4 commit c3005f4Copy full SHA for c3005f4
844.cpp
@@ -0,0 +1,42 @@
1
+class Solution {
2
+public:
3
+ bool backspaceCompare(string S, string T) {
4
+
5
+ stack<char>S1;
6
+ stack<char>S2;
7
8
+ int i=0;
9
+ int j=0;
10
11
+ while(i<S.length())
12
+ {
13
+ if(!S1.empty() && S[i]=='#')
14
15
+ S1.pop();
16
+ }
17
+ if(S[i]!='#')
18
19
+ S1.push(S[i]);
20
21
22
+ i++;
23
24
25
+ while(j<T.length())
26
27
+ if(!S2.empty() && T[j]=='#')
28
29
+ S2.pop();
30
31
+ if(T[j]!='#')
32
33
+ S2.push(T[j]);
34
35
36
+ j++;
37
38
39
+ return (S1==S2);
40
41
42
+};
0 commit comments