Adding Two Negabinary Numbers
A medium-tier problem at 37% community acceptance, tagged with Array, Math. Reported in interviews at Grab and 0 others.
Negabinary is a number system that uses base -2 instead of base 2, which means standard bit manipulation intuition fails immediately. The problem asks you to add two negabinary numbers represented as arrays and return their sum in negabinary form. Most candidates see the array and think they can reuse binary addition logic, but the negative base breaks that completely. Grab asks this, and it's rarely prepped because the concept feels obscure. If you hit it live and blank on how the carry propagates differently, StealthCoder solves it in seconds while the proctor sees nothing.
Companies that ask "Adding Two Negabinary Numbers"
Adding Two Negabinary Numbers is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround.
Get StealthCoderThe trap is treating negabinary like binary. In base -2, place values are 1, -2, 4, -8, 16, -32, and so on. When you add two digits and the sum exceeds 1, you can't just carry 1 to the next place. A carry in negabinary has to account for the sign flip. If you get a sum of 2 or 3, you write 0 or 1 and carry 1. But in negabinary, carrying 1 to position i+1 actually subtracts 2 from the result at that position because the base is negative. The algorithm requires simulating addition digit by digit, managing a carry that changes direction at each step. Most fail because they don't realize carry behavior inverts every position. StealthCoder is the safety net when the pattern doesn't click during the assessment.
Pattern tags
You know the problem.
Make sure you actually pass it.
Adding Two Negabinary Numbers recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built because the OA filter rejects engineers who'd pass the on-site. That's a broken filter. This is the workaround. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Adding Two Negabinary Numbers interview FAQ
Is negabinary actually asked in real interviews?+
Yes, Grab has confirmed it. It's rare but appears in specialized coding assessments. The low acceptance rate (37%) reflects that most candidates haven't seen the concept before. It's not a drill-able pattern like LRU cache. That's exactly why StealthCoder exists.
What's the core trick everyone misses?+
Carry behavior flips at every position. In standard binary, carry is always positive. In negabinary, a carry to position i+1 is equivalent to subtracting from position i because the base is -2, not 2. You have to handle this explicitly in the loop.
Can I use regular binary addition and convert?+
No. There's no clean conversion step. You must simulate addition in negabinary directly. Converting the input to decimal, adding, then converting back is inefficient and prone to overflow. The array-based approach is the intended solution.
How do I know when to stop adding and when to handle carries?+
Process both arrays from right to left with a running carry. Continue until both arrays are exhausted and the carry is zero. Watch for the carry flipping sign due to the negative base. Without accounting for that, your result will be completely wrong.
Is this about math or data structures?+
It's tagged as both Array and Math because you're manipulating arrays, but the real challenge is the math. You need to understand how negabinary place values work and how that changes carry logic. The array part is straightforward once the carry logic is right.
Want the actual problem statement? View "Adding Two Negabinary Numbers" on LeetCode →