Skip to content

Commit fa462a1

Browse files
committed
Runtime: 0 ms (Top 100.00%) | Memory: 6.4 MB (Top 28.52%)
1 parent a9b53a9 commit fa462a1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

scripts/algorithms/B/Backspace String Compare/Backspace String Compare.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1+
// Runtime: 0 ms (Top 100.00%) | Memory: 6.4 MB (Top 28.52%)
12
class Solution {
23
public:
34
bool backspaceCompare(string s, string t) {
45
stack<int> st1;
56
stack<int> st2;
67
int len = s.length();
78
int len2 = t.length();
8-
9+
910
for(int i=0; i<len; i++){
1011
if(s[i] != '#'){
1112
st1.push(s[i]);
1213
}
1314
else{
1415
if(!st1.empty()){
15-
st1.pop();
16+
st1.pop();
1617
}
1718
}
1819
}
@@ -22,11 +23,11 @@ class Solution {
2223
}
2324
else{
2425
if(!st2.empty()){
25-
st2.pop();
26+
st2.pop();
2627
}
2728
}
2829
}
29-
30+
3031
while(!st1.empty() && !st2.empty()){
3132
if(st1.top() != st2.top()){
3233
return false;
@@ -39,4 +40,4 @@ class Solution {
3940
}
4041
return false;
4142
}
42-
};
43+
};

0 commit comments

Comments
 (0)