Abstract Confusions

Complexity is not a cause of confusion. It is a result of it.

Category Archives: Python

Interesting Interview Question: Check if a String is Rotated

Found an interesting interview question at Stackoverflow.

How will you find a string ‘a’ is a rotated string of some string ‘b’ (say, or some other reference string, but known)?

a= ‘stackoverflow’, b = ‘overflowstack’, then ‘a’ is rotated string of ‘b’.

a= ‘stackoverflow’, b= ‘flowrevostack’, then ‘a’ is NOT rotated string of ‘b’.

What makes this interview question interesting is seemingly difficult question (check Jon Skeet’s answer, he admitted the actual answer is simple and elegant).

Read more of this post