We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a9b53a9 commit fa462a1Copy full SHA for fa462a1
scripts/algorithms/B/Backspace String Compare/Backspace String Compare.cpp
@@ -1,18 +1,19 @@
1
+// Runtime: 0 ms (Top 100.00%) | Memory: 6.4 MB (Top 28.52%)
2
class Solution {
3
public:
4
bool backspaceCompare(string s, string t) {
5
stack<int> st1;
6
stack<int> st2;
7
int len = s.length();
8
int len2 = t.length();
-
9
+
10
for(int i=0; i<len; i++){
11
if(s[i] != '#'){
12
st1.push(s[i]);
13
}
14
else{
15
if(!st1.empty()){
- st1.pop();
16
+ st1.pop();
17
18
19
@@ -22,11 +23,11 @@ class Solution {
22
23
24
25
if(!st2.empty()){
- st2.pop();
26
+ st2.pop();
27
28
29
30
31
while(!st1.empty() && !st2.empty()){
32
if(st1.top() != st2.top()){
33
return false;
@@ -39,4 +40,4 @@ class Solution {
39
40
41
42
-};
43
+};
0 commit comments