Domanda di colloquio di Amazon

Remove all consecutive characters in a string. bottom -> boom-> bm (return "bm")

Risposte di colloquio

Anonimo

4 lug 2018

Using stack

Anonimo

31 ott 2017

Used a simple iterative approach that maintained a variable that stored the current character. Mistake made was that I used string manipulation, which I wouldve changed had I had more time. Smarter solution would have been to declare an auxiliary array of boolean values representing whether the characters would be present in the string. Perform one pass where you set all the boolean values and a second to actually create the final string.