FastPrepAdd Two Numbers Stored as Linked Lists
Problems/Add Two Numbers Stored as Linked Lists

Add Two Numbers Stored as Linked Lists

Capital One logoCapital One● MediumINTERNFULLTIMENEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Five Capital One reports from 2016 to 2021, from intern, new grad and other software engineer candidates, describe adding two numbers kept one digit per node in linked lists, in the final round. One compares it to a well-known practice version where the first digit comes first and says it had more to it, without saying what.

The reports do not settle the digit order or give limits. Here the head holds the first digit, as in that practice version, the inputs have no leading zeros, and each number has at most 1000 digits. The unexplained extra part is not included. These are our choices.

Our version is about 80% the same as the reported questions.

Read each of l1 and l2 from the head to get a number: the head is its leading digit and every following node is the next digit. So 3 → 0 → 8 means 308, and no number here is negative.

Add the two numbers and give back the total, written the same way as a new list. Write no extra zeros at the front; a total of zero is one node holding 0.

Function

addTwoNumbers(l1: ListNode, l2: ListNode) → ListNode

Examples

Example 1

l1 = [3,0,8]l2 = [9,4]return = [4,0,2]
l1
308
l2
94
return
402

The lists stand for 308 and 94. 308 + 94 = 402, which becomes 4 → 0 → 2.

Example 2

l1 = [6]l2 = [4,9,9,6]return = [5,0,0,2]
l1
6
l2
4996
return
5002

6 + 4996 = 5002. The carry from the last digit moves through two 9s before it stops.

Example 3

l1 = [8,8]l2 = [1,2]return = [1,0,0]
l1
88
l2
12
return
100

88 + 12 = 100. The total has one more digit than either number, so the answer list is longer than both inputs.

Constraints

  • Each list has between 1 and 1000 nodes.
  • 0 <= Node.val <= 9
  • No list has a leading zero, except a list that is the single node 0.

More Capital One Onsite Interview questions

  • Digit-Coded Card ValidationONSITE INTERVIEW · Seen Nov 2026
  • Sort ColorsONSITE INTERVIEW · Seen Oct 2026
  • Virtual Card Transaction ValidatorONSITE INTERVIEW · Seen Oct 2026
  • Banking System with Top ActivityONSITE INTERVIEW · Seen Sep 2026
  • Transaction Event StoreONSITE INTERVIEW · Seen Jul 2026
  • Shortest Path in an Unweighted GraphONSITE INTERVIEW · Seen Jul 2026
  • Duplicate Transactions Within 60 SecondsONSITE INTERVIEW · Seen May 2026
  • LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen May 2026
  • Cashback TrackerONSITE INTERVIEW · Seen Nov 2025
  • Reverse a StringOA · ONSITE INTERVIEW · Seen Oct 2025

Similar questions at other companies

  • Add Two Numbers IIBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Subtract Forward-Order Linked-List NumbersMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Add Two Numbers Stored in Reversed ListsExpedia · ONSITE INTERVIEWExpedia interview questions
  • Add Numbers Stored in Four-Digit ChunksZipRecruiter · ONSITE INTERVIEWZipRecruiter interview questions
  • Add Forward Linked-List Numbers Using RecursionPeopleStrong · PHONE SCREENPeopleStrong interview questions
  • Add NumbersCisco · OACisco interview questions
  • Binary Linked List to DecimalJP Morgan Chase · OAJP Morgan Chase interview questions
  • Integers With Multiple Sum of Two CubesCharta Health · PHONE SCREEN · ONSITE INTERVIEWCharta Health interview questions
  • Reverse a Sublist of a Linked ListSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Dice-Walk Winning ProbabilityGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions

Capital One interview experiences

  • Capital One Experienced Engineer Power Day and OA: 6 Experiences
  • Capital One New Grad OA Questions: 14 Experiences (Part 2 of 2)
  • Capital One TDP Agentic Round (AI Coding): 7 Experiences
  • Capital One SWE Power Day, Level Not Reported: 6 Experiences
  • Capital One TIP Intern OA and Power Day: 13 Experiences
  • Capital One TDP Agentic Power Day: 25 Experiences (Part 1 of 2)
All Capital One interview questionsSee Capital One hiring insights
Saved
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution {
    public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
        // Write your code here.
    }
}
Checking account…