Add Binary Strings
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Given two strings a and b that each represent a non-negative integer written in **base 2**, return the binary string that represents their sum.
Each input string contains only the characters '0' and '1'. You must perform the addition directly on the string representations and return the result as a binary string. Do not rely on converting the entire inputs to a fixed-width integer type, since the operands may be longer than a built-in integer can hold; you should add the bits column by column while carrying overflow, just like grade-school addition.
The returned string should have **no leading zeros**, except that the value 0 itself is represented as the single character "0".
Examples
Constraints
- 1 <= a.length, b.length <= 10000
- Each of `a` and `b` consists only of the characters '0' and '1'.
- Neither `a` nor `b` contains leading zeros, except when the string is exactly "0".
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.