Last active
April 11, 2020 05:37
-
-
Save javi-aire/8cd8dc3b87d92628096546332eb533f2 to your computer and use it in GitHub Desktop.
Problem 9/30 of LeetCode 30-day challenge
This file contains hidden or 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
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