DEV Community

loading...

Discussion on: A coding interview question asked at Google

Collapse
bilyachenkooy profile image
Olexiy

You can try to go in backward direction whule comparing char by char without strings creation. In best case you will determine that strings are different at first iteration. At worst - iterate for max(n, m) times. And in any case you will only need constant extra memory allocation