How to solve this problem ,

Revision en4, by abcyyyy, 2018-08-13 23:31:40

How to solve a question where the string is first circularly rotated by 1 letter, then by 2 letter and soon , at what time the modified string will be equal to original string? these strings are made up using 'a' and 'b' only.

for eg: aabaab is the string on first letter rotation it will become abaaba on second rotation it will become aabaab so answer is 2.

I tried to solve this question but could only do this only by brute force. https://pasteboard.co/Hz1WUBx.jpg

Any help will be appreciated.

Tags #strings, #c++

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English abcyyyy 2018-08-13 23:31:40 35 Tiny change: ' force. \n\nAny he' -> ' force. \nhttps://pasteboard.co/Hz1WUBx.jpg\n\nAny he'
en3 English abcyyyy 2018-08-13 23:27:27 69 Reverted to en1
en2 English abcyyyy 2018-08-13 23:26:52 69
en1 English abcyyyy 2018-08-13 23:25:08 501 Image is attached (published)