Lexicographically Smallest Rotation
Among all |S| rotations of S, print the lexicographically smallest one.
Input: one line with the string S.
Output: the smallest rotation.
Constraints:
- 1 ≤ |S| ≤ 2000
- lowercase letters
Sample Tests
Input 1
cba
Output 1
acb
Input 2
baca
Output 2
abac
Discussion (opens after you solve — no spoilers before)
No comments yet.