Sum Two Huge Ad Spend Totals Stored Digit by Digit in Reverse

Last updated: November 29, 2026

Quick Overview

Two non-negative integers too large for a machine word are stored as singly linked lists of decimal digits, least significant digit first. Return their sum as a new list in the same format.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Medium

0

0

0 solved


Two non-negative integers too large for a machine word are stored as singly linked lists of decimal digits, least significant digit first. Return their sum as a new list in the same format.

A Google phone screen problem dressed as big-number arithmetic for ads billing aggregates. The interviewer is checking carry handling, unequal lengths, and the final carry node, all in one clean loop.

What the Interviewer Expects
  • Walk both lists at once, treating a missing node as 0
  • Propagate carry with divmod
  • Continue while either list or the carry remains
  • Build the result with a dummy tail
  • Do not convert to a Python int as the main solution
Key Topics to Cover
linked list
big integer arithmetic
carry propagation
sentinel node
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • Digits are stored most significant first instead.
  • Subtract the smaller number from the larger.
  • Support arbitrary bases, for example base 2^32 limbs.
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Inputs: heads a and b, digits 0-9, least significant first, no leading zeros except the number 0 itself.
  • Output: a new list for a + b in the same format.
  • O(max(m, n)) time....
High-Level Design

This is grade-school addition, which naturally runs from the least significant digit, so the reversed order is a gift. Keep a carry. On each step take the current digit of each list (0 if that list is...


Submit Your Answer
Markdown supported