Skip to content

Add Binary

EasyBit Manipulation & Math
Decode it first. Clues, constraints, pattern and plan before any code.

a and b are binary strings (only '0' and '1'). Return their sum, also as a binary string.

a = "11",   b = "1"     →  "100"
a = "1010", b = "1011"  →  "10101"
a = "0",    b = "0"     →  "0"

Constraints

  • 1 <= a.length, b.length <= 10^4
  • a and b consist only of '0' or '1' characters.
  • Neither string has leading zeros, except the number zero itself.