Aba repeats at 2 but how does it repeat at 4?


time 1: baa
time 2: aba
time 3: aba
time 4: baa (As len(“aba”) is 3 and 4 % 3 is 1, the array should be rotated backwards by 1)

Why is it mentioned in the examples that aba repeats itself at 2 and 4? I also checked through “see expected output” and I got the same answer.


Even I have same question. Can someone please guide on this?


Guys that is the iteration. On every successfull ans its multipication will be ans.Dont take it as lenght wise. 2 and 4th are iteration if I am not wrong.


As it’s written in the question that process repeats itself when string becomes equal to itself implying that at time 2: aba is o/p and at time 3 it’s baa (1 letter of string is circularly rotated as the process restarted) and at time 4: aba. I hope it’s clear now.