Given a binary string. We are allowed to do circular rotation of the string without changing the relative order of the bits in the string.
For Example, all possible circular rotation of string “011001” are:
101100 010110 001011 100101 110010
We are required to tell total number of distinct odd decimal equivalent possible of binary string, by doing circular rotation.
Input : 011001 Output : 3 Explanation: All odd possible binary representations are: ["011001", "001011", "100101"] Input : 11011 Output : 4 Explanation: All odd possible binary representations are: ["11011", "01111", "10111", "11101"]
It can be observed that a binary string can only be odd if it’s last bit is 1, because the value of last bit is 2^0.Hence, since we are doing circular rotation.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Maximum contiguous 1 possible in a binary string after k rotations
- Number of substrings with odd decimal value in a binary string
- Generate all rotations of a given string
- Minimum rotations required to get the same string
- Minimum rotations required to get the same String | Set-2
- Minimum circular rotations to obtain a given numeric string by avoiding a set of given strings
- Convert Hexadecimal value String to ASCII value String
- A Program to check if strings are rotations of each other or not
- Check if all rows of a matrix are circular rotations of each other
- Count rotations divisible by 4
- Check if two numbers are bit rotations of each other or not
- Check if strings are rotations of each other or not | Set 2
- Number of strings which starts and ends with same character after rotations
- Periodic Binary String With Minimum Period and a Given Binary String as Subsequence.
- Maximum splits in binary string such that each substring is divisible by given odd number
- Counting even decimal value substrings in a binary string
- Arrange a binary string to get maximum value within a range of indices
- Length of longest subsequence whose XOR value is odd
- Check if binary representations of 0 to N are present as substrings in given binary string
- Check in binary array the number represented by a subarray is odd or even
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.