JavaScript Coding Challenge/Interview Question: Same Char Collapse

Pubblicato il: 20 marzo 2020
sul canale di: Daily Coding Challenges
183
5

/*
Write a function same_char_collapse that takes in a string and
returns a collapsed version of the string. To collapse the string,
we repeatedly delete 2 adjacent characters that are the same until
there are no such adjacent characters. If there are multiple pairs
that can be collapsed, delete the leftmost pair. For example, we take
the following steps to collapse "zzzxaaxy": zzzxaaxy -- zxaaxy -- zxxy -- zy
*/


console.log(sameCharCollapse("zzzxaaxy")); // "zy" === because zzzxaaxy -- zxaaxy -- zxxy -- zy
console.log(sameCharCollapse("uqrssrqvtt")); // "uv" === because uqrssrqvtt -- uqrrqvtt -- uqqvtt -- uvtt -- uv


In questa pagina del sito puoi guardare il video online JavaScript Coding Challenge/Interview Question: Same Char Collapse della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Daily Coding Challenges 20 marzo 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 183 volte e gli è piaciuto 5 spettatori. Buona visione!