text of lowercase English letters and an integer step. Every second the string must change in two moves:
1. the first step characters are erased;
2. any step characters of your choice are appended to the end (they do not have to be the ones that were erased).
Both moves happen every second; you cannot skip a turn. Return the smallest positive number of seconds after which the string can be equal to the original text again.text="banana", step=2 → 3
After one second "nana" remains plus two free letters, but "nana" is not the start "bana". After two seconds it is "na" against "ba", still no. After three seconds nothing of the original is left, so all six letters can be written back.
text="abcab", step=3 → 1
Removing "abc" leaves "ab", which is exactly how the word starts. Appending "cab" brings back "abcab" after one second.
text="zzz", step=1 → 1
Any tail made of z matches the start of the word, so one second is enough.
text contains only lowercase English letterstext="banana", step=2
3
Run checks the first 3 tests in your browser. Submit checks all 111 tests on the server, hidden ones included.