Skip to content

re: A coding interview question asked at Google VIEW POST

re: Just compare starting from the end of the strings. When you see "-B" (possibly consecutively), you know you can skip stuff. O(n) time and O(1) spac...

Important thing when just skipping:
lets say we have "a,c,-B,-B" and we start from the back: we see a -B, so we skip the next character, now there is a c and then an a so we get ca (reversed), which is wrong. You need to count the -B s that are back to back and then remove as many "chars". also agree, real chars would be far better, also returning literal "true" and "false" hurts a lot

code of conduct - report abuse