Largest Binary Number using Cyclic shifts. Help Needed

Правка en1, от ghost1733, 2020-12-02 17:38:10

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 ?

Теги #string matching, binary bit, #bits

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский ghost1733 2020-12-02 17:38:10 759 Initial revision (published)