Given two binary strings, return their sum (also a binary string).
Input: a = "11", b = "1" Output: "100"
We strongly recommend you to minimize your browser and try this yourself first
The idea is to start from last characters of two strings and compute digit sum one by one. If sum becomes more than 1, then store carry for next digits.
Thanks to Gaurav Ahirwar for suggesting above solution. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
- Add n binary strings
- Bitwise AND of N binary strings
- Bitwise OR of N binary strings
- XOR two binary strings of unequal lengths
- Generate all binary strings without consecutive 1's
- Generate all binary strings from given pattern
- Count binary strings with twice zeros in first half
- Count number of binary strings without consecutive 1's
- Number of sub-strings in a given binary string divisible by 2
- Count of non-overlapping sub-strings "101" and "010" in the given binary string
- Number of binary strings such that there is no substring of length ≥ 3
- Count number of binary strings of length N having only 0's and 1's
- Generate Binary Strings of length N using Branch and Bound
- Given two binary strings perform operation until B > 0 and print the result
- Find the number of binary strings of length N with at least 3 consecutive 1s