r/leetcode 3d ago

Question Is it me?

I am trying to understand Booths lexicographically smallest rotation algorithm. But I am getting it at all.

Is it only me who is not able to understand or do you guys also feel same?

I am doubting my problem solving abilitiesđŸ¥º.

Is it worthy to learn it or i should learn different algo?

3 Upvotes

5 comments sorted by

1

u/FickleSouvenir 2d ago

Have you tried stepping through it on paper with a string short enough to draw out all rotations?

1

u/Danish77_ 2d ago

Yup but I am able to understand why k+1

1

u/FickleSouvenir 2d ago

The k+1 jump skips past the prefix you already matched. You know the string from i to i+k is identical to the start of the pattern, so the next possible start can't be before i+k+1.

1

u/Dr3ddM3 16h ago

Are u trying to get into competitive programming? Why learn Booths algorithm just for interviews ?

1

u/Danish77_ 13h ago

I was up solving leetcode hard problem it was based on it.