less than 1 minute read

Given two strings a and b that represent binary numbers, add them and return their sum, also as a string.

The input strings are guaranteed to be non-empty and contain only 1s and 0s.

Constraints

  • n ≤ 100,000 where n is the length of a
  • m ≤ 100,000 where m is the length of b

https://binarysearch.com/problems/Add-Binary-Numbers

Examples

Example 1

Input

  • a = 1
  • b = 1

Output

  • answer = 10

Example 2

Input

  • a = 111
  • b = 1

Output

  • answer = 1000

Solution

Leave a comment