Given a number N. The task is to find the minimum number of binary strings required to represent the given number as the sum of the binary strings.
Input : 131
Output : Minimum Number of binary strings needed: 3
111 10 10
Input : 564
Output :Minimum Number of binary strings needed: 6
111 111 111 111 110 10
- Store all digits of the given number in the array.
- Find the maximum digit in the array. This maximum number(maxi) indicates the number of binary strings required to represent the given number.
- Now, find maxi numbers by substuting 0’s and 1’s greadily.
Below is the implementation of the above approach:
Minimum No of binary strings needed: 6 111 111 111 111 110 10
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Number of distinct ways to represent a number as sum of K unique primes
- Count number of binary strings without consecutive 1's
- Number of sub-strings in a given binary string divisible by 2
- Number of binary strings such that there is no substring of length ≥ 3
- Count number of binary strings without consecutive 1’s : Set 2
- Find the number of binary strings of length N with at least 3 consecutive 1s
- Number of Binary Strings of length N with K adjacent Set Bits
- Minimum number of pairs required to make two strings same
- Count number of binary strings such that there is no substring of length greater than or equal to 3 with all 1's
- Minimum number of 1's to be replaced in a binary array
- Minimum number of operations required to sum to binary string S
- Minimum sub-array such that number of 1's in concatenation of binary representation of its elements is at least K
- Minimum number of operations on a binary string such that it gives 10^A as remainder when divided by 10^B
- Minimum number of swaps to make two binary string equal
- Minimum number of moves to make a binary array K periodic
- Minimum number of palindromic subsequences to be removed to empty a binary string
- Number of ways to split a binary number such that every part is divisible by 2
- Smallest number dividing minimum number of elements in the Array
- Smallest number dividing minimum number of elements in the array | Set 2
- Find a number which give minimum sum when XOR with every number of array of integers