Given n binary strings, return their sum (also a binary string).
Input: arr = ["11", "1"] Output: "100" Input : arr = ["1", "10", "11"] Output : "110"
- Initialize the ‘result’ as an empty string
- Traverse the input from i = 0 to n-1
- For each i, add arr[i] to the ‘result’. How to add ‘result’ and arr[i]? Start from the last characters of the two strings and compute digit sum one by one. If sum becomes more than 1, then store carry for next digits. Make this sum as the ‘result’
- The value of ‘result’ after traversing the entire input is the final answer
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.
- XOR of two Binary Strings
- Bitwise AND of N binary strings
- Bitwise OR of N binary strings
- Program to add two binary strings
- Generate all the binary strings of N bits
- XOR two binary strings of unequal lengths
- Generate all binary strings from given pattern
- Generate all binary strings without consecutive 1's
- Count number of binary strings without consecutive 1’s : Set 2
- Count number of binary strings without consecutive 1's
- Count binary strings with twice zeros in first half
- Count of binary strings of given length consisting of at least one 1
- Number of binary strings such that there is no substring of length ≥ 3
- 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
- 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
- Number of Binary Strings of length N with K adjacent Set Bits
- Generate Binary Strings of length N using Branch and Bound
- Build a DFA to accept Binary strings that starts or ends with "01"
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.