Add Two Numbers
Reported by candidates from Bloomberg's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks most first attempts at Add Two Numbers is dropping the final carry, and Bloomberg's October 2022 OA reportedly asked exactly this. Two linked lists hold digits in reverse order, and you return their sum as a new list. It's a linked-list walk with a carry, nothing fancier. If you've seen it, you'll finish fast. If you haven't, the edge cases will bite. Lists of different lengths and a leftover carry trip people up under a timer. If you blank mid-assessment, StealthCoder runs invisibly as a safety net and gives you the working solution on the spot.
The problem
Two nonnegative integers are stored in reverse digit order in linked lists l1 and l2. Each node stores one digit. Return their sum as a reverse-order digit linked list. Neither input has leading zeroes except the number zero. Function addTwoNumbers(l1: ListNode, l2: ListNode) → ListNode Examples Example 1 l1 = [2,4,3] l2 = [5,6,4] return = [7,0,8] 342 + 465 = 807. Example 2 l1 = [9,9,9] l2 = [1] return = [0,0,0,1] The final carry creates a new node. Constraints Each list has between 1 and 100 nodes. Every node value is between 0 and 9.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Reverse order is a gift. The head of each list is the ones digit, so you add left to right exactly like grade-school addition. Use a dummy head node, a carry variable, and loop while l1 or l2 or carry is nonzero. Each step: sum = carry + (l1 value or 0) + (l2 value or 0), new digit is sum % 10, carry is sum // 10. Append a node, advance whichever pointers exist. Return dummy.next. The classic pitfall is ending the loop when both lists run out and forgetting the carry, which breaks the [9,9,9] + [1] case. Another is converting to integers, which fails on long lists in many languages. Keep it pure pointer work. Time is O(max(m,n)), space is O(1) beyond the output. If your head goes empty during the live OA, StealthCoder is the hedge that hands you this loop.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Add Two Numbers cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as add two numbers. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Bloomberg's OA.
Bloomberg reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Add Two Numbers FAQ
What's the trick in Add Two Numbers?+
Simulate addition digit by digit with a carry. Use a dummy head, loop while either list or the carry is nonzero, treat missing nodes as 0, and append sum % 10 each step. The reverse order means no list reversal is needed.
How hard is this really for the Bloomberg OA?+
It's a standard easy-to-medium linked-list problem. The logic is short, but small mistakes cost you. Uneven list lengths and the final carry are where candidates lose test cases, not the core idea.
Can I just convert the lists to integers and add?+
Don't. Each list can hold up to 100 digits, which overflows fixed-width integers in many languages. Even where big integers work, it's extra code and extra risk. Walk the nodes and carry instead.
What edge cases should I test?+
Test [9,9,9] + [1] for the final carry, lists of different lengths, and [0] + [0]. Also check that single-node lists work. The constraints guarantee at least one node each, so you don't need null-input handling.
How do I prepare in 48 hours for this kind of question?+
Write this one from scratch twice with a dummy head until the loop is automatic. Then do a few other pointer problems like merging two sorted lists. The dummy node plus carry pattern covers a lot of linked-list questions.