JavaScript Coding Challenge/Interview Question: Same Char Collapse

Publicado em: 20 Março 2020
no canal de: 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


Nesta página do site você pode assistir ao vídeo on-line JavaScript Coding Challenge/Interview Question: Same Char Collapse duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Daily Coding Challenges 20 Março 2020, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 183 vezes e gostou 5 espectadores. Boa visualização!