All problems

Add Binary

Easy · bit manipulation

Two meters each display a number in binary, written as a string of the characters "0" and "1".

Given the strings a and b, return their sum, also written in binary as a string.

The inputs have no leading zeros (except for the number zero itself, which is written "0"), and the answer must follow the same rule.

Examples

Example 1

Input: a = "11", b = "1"

Output: "100"

3 + 1 = 4, which is 100 in binary.

Example 2

Input: a = "1010", b = "1011"

Output: "10101"

10 + 11 = 21, which is 10101 in binary.

Example 3

Input: a = "0", b = "0"

Output: "0"

Constraints