DIY: Add Binary

Solve the interview question "Add Binary" in this lesson.

Problem statement

In this challenge, you are given two binary numbers as strings. Implement a function that takes these strings as input, performs the binary addition, and returns the output in the form of a string.

Input

The inputs will be two binary numbers in the form of strings called a and b. For example, consider the following inputs:

a = "1010100"
b = "0100011"

Output

The function will return a string that represents the binary number calculated by the addition of the inputs. The following is the output for the inputs mentioned above is given below:

"1110111"

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.