Add Binary Numbers
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 1
s and 0
s.
Constraints
n ≤ 100,000
wheren
is the length ofa
m ≤ 100,000
wherem
is the length ofb
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
Leave a comment