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
- Generate all binary strings from given pattern
- Generate all binary strings without consecutive 1's
- Count binary strings with twice zeros in first half
- Count number of binary strings of length N having only 0's and 1's
- Count number of binary strings without consecutive 1's
- Count of non-overlapping sub-strings "101" and "010" in the given binary string
- Generate all binary strings of length n with sub-string "01" appearing exactly twice
- 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
- Number of Binary Strings of length N with K adjacent Set Bits
- Program to check if two strings are same or not
- A Program to check if strings are rotations of each other or not