Controls

1-20 lowercase letters

Problem

Given a circular string (necklace), find rotation that is smallest lexicographically.

Lexicographical order: Compare character by character, first differing character determines order. Example: abac < acab because 'b' < 'c'.

Booth's Algorithm: Finds minimal rotation in O(n) time using two pointers that compare rotations and skip non-optimal positions.

String Visualization