You are viewing a single comment's thread. Return to all comments →
Solution using Javascript using recursion and regex:
const regex = /([a-z])\1/g; function superReducedString(s) { let replaced = removeAdjacents(s); while(checkForAdjacents(replaced)) { replaced = removeAdjacents(replaced) } if(replaced === "") { return "Empty String" } return replaced } const removeAdjacents = (str) => { return str.replaceAll(regex, ''); } const checkForAdjacents = (str) => { return regex.test(str); }
Seems like cookies are disabled on this browser, please enable them to open this website
Super Reduced String
You are viewing a single comment's thread. Return to all comments →
Solution using Javascript using recursion and regex: