Problem Statement: Input Format
First line contain a no. , no. of bits in binary number. Second line contain a binary number of size .
Constraints
Output Format
Output the maximum no. that this Binary no. can result using cyclic shifts into modulo ().
Sample Input 0
5 00101 Sample Output 0
20 Explanation 0
For first case maximum is if no. is rotated to give string 10100 which is 20.
Sample Input 1
6 011010 Sample Output 1
52 Explanation 1
For second case maximum is if no. is rotated to give string 110100 which is 52.
Sample Input 2
4 1100 Sample Output 2
12
I found a solution using suffix array. but is there any simple solution ?
Lexicographically minimal string rotation
Hope this will help you.
Thanks, really helpful