Skip to content

Instantly share code, notes, and snippets.

@esco
Last active September 9, 2022 10:59
Show Gist options
  • Save esco/1e04f6326bc818c45c5164349da1c862 to your computer and use it in GitHub Desktop.
Save esco/1e04f6326bc818c45c5164349da1c862 to your computer and use it in GitHub Desktop.
Leetcode 844. Backspace String Compare
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('')
}
@zain12321
Copy link

owesome bro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment