Last active
September 9, 2022 10:59
-
-
Save esco/1e04f6326bc818c45c5164349da1c862 to your computer and use it in GitHub Desktop.
Leetcode 844. Backspace String Compare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function backspaceCompare(S, T) { | |
const s = evaluate(S) | |
const t = evaluate(T) | |
return s === t | |
}; | |
function evaluate(str) { | |
const output = [] | |
for (const char of str) { | |
if (char !== '#') { | |
output.push(char) | |
} else { | |
output.pop() | |
} | |
} | |
return output.join('') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
owesome bro