All questions
EasyStrings · Digit-by-Digit Addition
Binary Addition Calculator
Written by a community member ·
0
Build a calculator that adds two non-negative binary numbers. The inputs are strings containing only 0 and 1; they have no leading zeroes unless the number is "0". Return their sum as a binary string, also with no leading zeroes except for "0". For example, "1" + "1" returns "10" because the sum is decimal 2, written in binary. Do not convert the inputs to decimal integers; perform the addition by processing the binary digits and carrying as needed.
Example 1: add_binary("1", "1") returns "10".
Example 2: add_binary("101", "11") returns "1000" (binary 5 + binary 3 = binary 8).
Each input may contain up to 100,000 digits.