#### Loading...

Leaderboard
Showing:
Handle Score
@Ibrahim Nash 5725
@blackshadows 5685
@akhayrutdinov 5111
@mb1973 4989
@Quandray 4908
@saiujwal13083 4156
@sanjay05 3762
@marius_valentin_dragoi 3511
@sushant_a 3453
@KshamaGupta 3318
@the_coder95 3302
Complete Leaderboard
Add Binary Strings
Medium Accuracy: 12.25% Submissions: 910 Points: 4

Given two binary strings A and B consisting of only 0s and 1s. Find the resultant string after adding the two Binary Strings.
Note: The input strings may contain leading zeros but the output string should not have any leading zeros.

Example 1:

Input:
A = "1101", B = "111"
Output: 10100
Explanation:
1101
+ 111
10100


â€‹Example 2:

Input:
A = "10", B = "01"
Output: 11
Explanation:
10
+ 01
11


User Task:
You don't need to read input or print anything. Your task is to complete the function addBinary() which takes 2 binary string A and B and returns a binary string denoting the addition of both the strings.

Expected Time Complexity: O(max(|A|, |B|)).
Expected Auxiliary Space: O(max(|A|, |B|)) (for output string).

Constraints:
1 <= |A|, |B| <= 1000000

to report an issue on this page.

### Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

#### My Submissions:

Login to access your submissions.

Add Binary Strings