FastPrepMean of Three Numbers Stored as Linked Lists
Problems/Mean of Three Numbers Stored as Linked Lists

Mean of Three Numbers Stored as Linked Lists

Capital One logoCapital One● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A 2021 Capital One TDP report names a final-round coding question about the mean of three very large numbers kept in linked lists. Two 2022 TDP reports seem to describe pieces of the same question. One is about summing three such numbers. The third gives just one detail: an average had to be computed from linked lists.

None of them gives the digit order, how to round, or how long the numbers are. Here each number is stored one digit per node with the first digit at the head. You return the mean of the three numbers rounded down, also as a linked list. Each number has at most 1000 digits. These are our choices.

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

Each of a, b and c is a linked list that spells out a non-negative whole number, one digit per node, read from the head. For example, 4 → 5 → 6 means 456.

Return the mean of the three numbers, (a + b + c) / 3 rounded down, as a linked list in the same form. The answer has no leading zeros, except that the number 0 is a single node 0.

Function

meanOfThree(a: ListNode, b: ListNode, c: ListNode) → ListNode

Examples

Example 1

a = [4,5,6]b = [7,8]c = [9,9,9]return = [5,1,1]
a
456
b
78
c
999
return
511

The numbers are 456, 78 and 999. Their sum is 1533, and 1533 / 3 = 511 exactly, so the answer is 5 → 1 → 1.

Example 2

a = [1]b = [0]c = [0]return = [0]
a
1
b
0
c
0
return
0

The sum is 1. One third of 1 rounds down to 0, so the answer is a single node 0.

Example 3

a = [9,9,9,9,9]b = [9,9,9,9,9]c = [2]return = [6,6,6,6,6]
a
99999
b
99999
c
2
return
66666

99999 + 99999 + 2 = 200000. Dividing by 3 gives 66666 with 2 left over, which is dropped, so the answer is five nodes of 6.

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

  • LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • LRU CacheServiceNow · PHONE SCREEN · ONSITE INTERVIEW
  • First-Fit Memory AllocatorGoogle · ONSITE INTERVIEW
  • Least Recently Used CacheMicrosoft · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Babysitter Quote with Hourly RatesUpstart · ONSITE INTERVIEW
  • LRU CacheAMD · ONSITE INTERVIEW
  • LRU CacheApple · PHONE SCREEN · ONSITE INTERVIEW
  • Least Recently Used CacheByteDance · PHONE SCREEN · ONSITE INTERVIEW
  • Add Two Numbers IIBloomberg LP · PHONE SCREEN · ONSITE INTERVIEW
  • Expected Value of Modified DiceJane Street · ONSITE INTERVIEW
See 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 meanOfThree(ListNode a, ListNode b, ListNode c) {
        // Write your code here.
    }
}
Checking account…