Skip to content

Commit 8023f07

Browse files
authored
Create 844-backspace-string-compare.js
1 parent 668c150 commit 8023f07

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

844-backspace-string-compare.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @param {string} S
3+
* @param {string} T
4+
* @return {boolean}
5+
*/
6+
const backspaceCompare = function(S, T) {
7+
return chk(S) === chk(T)
8+
};
9+
10+
function chk(str) {
11+
const s = []
12+
for(let i = 0, len = str.length; i < len; i++) {
13+
if(str[i] === '#') s.pop()
14+
else s.push(str[i])
15+
}
16+
return s.join('')
17+
}

0 commit comments

Comments
 (0)