Given a decimal number m, convert it into a binary string and apply n iterations, in each iteration 0 becomes “01” and 1 becomes “10”. Find ith(based indexing) index character in the string after nth iteration.
Input : m = 5, n = 2, i = 3 Output : 1 Input :m = 3, n = 3, i = 6 Output : 1
Recommended: Please solve it on “PRACTICE“first, before moving on to the solution.
1. Change a decimal number into binary and store in string s.
2. Run loop n times in each iteration. Run another loop of string
length s to convert 0 to “01” and 1 to “10” and store in another string s1.
After completion of each iteration, assign string s1 to s.
3. At last Return the value of ith index in string s.
Refer Set-2 for an optimized solution.
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.
- Find i’th index character in a binary string obtained after n iterations | Set 2
- Find the number obtained after concatenation of binary representation of M and N
- Kth character from the Nth string obtained by the given operations
- String obtained by reversing and complementing a Binary string K times
- Smallest string obtained by removing all occurrences of 01 and 11 from Binary String
- Lexicographically smallest string obtained after concatenating array
- Largest string obtained in Dictionary order after deleting K characters
- Fill array with 1's using minimum iterations of filling neighbors
- Find the character in first string that is present at minimum index in second string
- Check if frequency of character in one string is a factor or multiple of frequency of same character in other string
- Find last index of a character in a string
- Check if a string can be obtained by rotating another string 2 places
- Check if a string can be obtained by rotating another string d places
- Check if a string can be obtained by appending subsequences of another string
- Check if string S2 can be obtained by appending subsequences of string S1
- Find a string such that every character is lexicographically greater than its immediate next character
- Program to find the kth character after decrypting a string
- Index of character depending on frequency count in string
- Largest index for each distinct character in given string with frequency K
- Maximum repeating character for every index in given String
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.