Skip to content

Instantly share code, notes, and snippets.

@javi-aire
Last active April 11, 2020 05:37
Show Gist options
  • Save javi-aire/8cd8dc3b87d92628096546332eb533f2 to your computer and use it in GitHub Desktop.
Save javi-aire/8cd8dc3b87d92628096546332eb533f2 to your computer and use it in GitHub Desktop.
Problem 9/30 of LeetCode 30-day challenge
let backspaceCompare = function(S, T) {
let string_s = S.split('').reduce((acc, char, index) => {
if(char === '#') {
acc.pop();
} else {
acc.push(char);
}
return acc;
}, []).join('');
let string_t = T.split('').reduce((acc, char, index) => {
if(char === '#') {
acc.pop();
} else {
acc.push(char);
}
return acc;
}, []).join('');
return string_s === string_t;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment