P20737 [GeeksforGeeks] Add binary strings3805
普及
题目描述

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
Your 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| ≤ 10^{6}

输入格式

见题面

输出格式

见题面

样例输入
A = "1101", B = "111"
样例输出
10100