It's realy simple if you use python
Example 1:
Input: a = "11", b = "1"
Output: "100"
Example 2:
Input: a = "1010", b = "1011"
Output: "10101"
Here we use the mathod of python int (a,2) to convert the data to binary only one line commit
class Solution:
def addBinary(self, a: str, b: str) -> str:
return bin(int(a, 2) + int(b, 2))[2:]
We use the python int convert method let us can write this answer fast