Add Two Payout Amounts Stored as Most-Significant-First Digit Lists
Last updated: November 29, 2026
Quick Overview
A legacy payments service stores large payout amounts as singly linked lists of decimal digits, most significant digit first. Given two such lists, return a new list holding their sum in the same format, without reversing the inputs.
Uber
November 29, 20260
0
0 solved
A legacy payments service stores large payout amounts as singly linked lists of decimal digits, most significant digit first. Given two such lists, return a new list holding their sum in the same format, without reversing the inputs.
A linked list problem in the style of Uber's technical screens, set in payouts where amounts can exceed fixed-width integers. The interviewer checks carry handling and whether you can avoid mutating input lists that other code still reads.
What the Interviewer Expects
- Asks whether inputs may be mutated
- Uses stacks to process digits from least significant
- Builds the result by prepending nodes
- Handles a final carry
- Handles lists of different lengths
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you do this with O(1) extra space besides the output?
- How would you subtract two amounts in this format?
- Why not just convert to Python ints, and when would that be wrong in other languages?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: two non-empty lists of digits 0 to 9, most significant first, no leading zeros except the number 0 itself. Output: a new list with the sum. Inputs must not be modified because other readers hol...
High-Level Design
Push each list's digits onto a stack so they pop least significant first. Pop from both (using 0 when one runs out), add with the carry, and prepend a new node holding total % 10. Continue while eit...