Add Binary

Given two binary strings a and b, return their sum as a binary string.

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.
Saving… · 2 lines
class Solution:
def addBinary(self, a: str, b: str) -> str:
Console

Click Run to execute sample tests.