Add two binary strings of up to 100,000 digits each and return the sum as a binary string with no leading zeros, without relying on a built-in big-integer type.
Unlock detailed company stats for this questionUpgrade
Two strings a and b contain only the characters 0 and 1, and each is a non-negative integer written in base 2. Return their sum as a binary string with no leading zeros. Each string can be from 0 to 100,000 characters long, so the values do not fit in a machine integer; the test tells you not to rely on a built-in arbitrary-precision integer type and to implement the addition yourself. An empty input is allowed by the limits; the original does not say how to read it, and zero is the natural choice. Example: 1011 plus 110 is 10001.
Community answers
No answers contributed by the community yet.
Related questions
Add two non-negative integers given as digit strings and return the sum, and explain the time and space complexity of your approach.You are given a function that can add only two single digits. Using it, write a function that adds two non-negative integers supplied as strings and returns the sum as a string.Related courses

Course

