Smallest rotation

Write codeHard35 min

Your task

Given a non-empty string s of lowercase letters (1 <= len(s) <= 10^5), return the starting index i (0 <= i < len(s)) such that the rotation s[i:] + s[:i] is lexicographically smallest. If several indices give the same smallest rotation, return the smallest such index.

Examples

smallest_rotation_index(s: str) -> int
Example 1
Inputsmallest_rotation_index("bbaaccaadd")
Output2