Given string S, and let K be the minimum number of rotations required to get the same string.
For Example: (1) For S = "aaaa", K = 1 (2) For S = "abcabc", K = 3 (3) For S = "abcdef", K = 6
Now my question is, can there be any string for which K > len(S)/2 and K < len(S) ? If not, can someone please help me prove it?
In your example (3), K is greater than len(S) / 2.
You asked the wrong question?
Sorry I asked the wrong question. Have updated the question now. Can you please check? Can K > len(S)/2 && K < len(S)?
Auto comment: topic has been updated by yesnomaybe (previous revision, new revision, compare).
Auto comment: topic has been updated by yesnomaybe (previous revision, new revision, compare).
Not possible, because K can only be divisor of N, and there is no such divisor greater than N/2 and less than N.
Can you please share the intuition behind why K needs to be divisor of N?
Sorry, can't share the intuition because I just realised that this question is being asked in google foobar challenge.(Almost same with different story)
I am preparing for interviews and came across this question, which seems like a standard question. Here's the question link that I was trying to solve btw https://www.interviewbit.com/problems/stringoholics/ for which solution has been provided as well.
While solving, I came across the question that I asked and was not able to wrap my head around it.
Also there has been discussion on same question https://codeforces.net/blog/entry/61192