← Google Interview Insights

Google·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jul 2026

Summary

Google SWE interview with a linked list addition problem. Pretty classic stuff but the O(1) space constraint is where things get interesting and where I nearly tripped up.

Questions Asked (1)

Q1

You're given two singly linked lists representing non-negative integers stored in reverse order, one digit per node. Add the two numbers and return the result as a new linked list, also in reverse order. Do it in O(n + m) time and O(1) extra space, not counting the output.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The reverse storage is actually a gift because you can traverse both lists from head to tail and that already gives you the digits in addition order, least significant first.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints and edge cases, then propose a two-pointer traversal that adds digits while carrying over, reusing the input lists to achieve O(1) extra space. Emphasize that the reverse order simplifies addition, and discuss how to handle carry propagation and list length differences.

Pro tip: Mention that you can reuse the longer input list to store the result, avoiding extra space, but be prepared to discuss the trade-off of mutating inputs. Also, explicitly handle the final carry by appending a new node if needed.

1. Clarify requirements and edge cases

Ask about input constraints (e.g., non-negative integers, leading zeros, empty lists) and confirm that the output should be a new list or if reusing inputs is acceptable. Discuss time and space complexity expectations.

2. Outline the algorithm

Explain that you will traverse both lists simultaneously, summing corresponding digits plus any carry, and building the result list in reverse order. Use a dummy head to simplify list construction.

3. Handle carry and length differences

Describe how to continue traversal if one list is longer, and how to propagate the carry. Ensure that after both lists are exhausted, any remaining carry is added as a new node.

4. Optimize for O(1) extra space

Propose reusing the nodes of the longer input list to store the result, thus achieving O(1) extra space (excluding the output). Discuss the trade-off of mutating the input lists.

5. Analyze complexity and test

State that time complexity is O(max(n, m)) and space is O(1) extra. Walk through a few test cases, including different lengths and carry propagation.

Key Points to Mention

  • Time complexity O(n + m) and space complexity O(1) extra space (excluding output)
  • Use of a dummy head to simplify result list construction
  • Carry propagation and handling of final carry
  • Reusing input list nodes to achieve O(1) extra space, with trade-off of mutating inputs
  • Edge cases: empty lists, different lengths, carry at the end, leading zeros
  • Clarification that reverse order simplifies addition (least significant digit first)

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.