Google interview question

Given 2 strings containing regular characters and backspace characters (represented by "<"), return true if both strings are the same after all backspaces are processed and false otherwise. ie) should return true for "abc<<de<f" and "adca<<f"

Interview Answer

Anonymous

28 Nov 2018

it could be solved by a diff ways. Like using 2 stacks - add characters on top and delete top once you faced with <. After that you can pop chars from each stack and compare. It requires O(n) memory.