Add Binary
Given two binary strings a and b, return their sum as a binary string.
The input strings represent non-negative integers in base 2. You should add them using binary addition and return the resulting binary representation as a string.
Example 1
Input
a = "11", b = "1"Output
"100"11 is 3 and 1 is 1, so their sum is 4, which is 100 in binary.Example 2
Input
a = "1010", b = "1011"Output
"10101"1010 is 10 and 1011 is 11, so their sum is 21, which is 10101 in binary.Constraints
- 1 <= a.length, b.length <= 10^4
- a and b consist only of '0' or '1' characters
- Each string does not contain leading zeros except for the zero itself