FastPrepMissing Number
Problems/Missing Number

Missing Number

Capital One logoCapital One● EasyINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Four Capital One intern reports from 2020 and 2021 include a missing number question among their interview coding questions. In one, the numbers in the array run in sequence with a single gap. Another frames it as scanning an array for the value that is not there. The other two give only the name.

The reports do not say where the range starts or whether the array is sorted. Here the numbers come from 0 to n, exactly one is missing, and the array can be in any order. The size limit is our choice.

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

nums holds n different whole numbers, each between 0 and n. Exactly one number from that range is not in nums. Return it.

nums can be in any order.

Function

missingNumber(nums: int[]) → int

Examples

Example 1

nums = [4,0,5,1,3]return = 2

There are 5 numbers, so they come from 0 to 5. Checking each: 0, 1, 3, 4 and 5 appear, and 2 does not.

Example 2

nums = [1]return = 0

With one number the range is 0 to 1. Only 1 is present, so 0 is the gap.

Example 3

nums = [0,1,2,3,4,5,6]return = 7

Seven numbers means the range 0 to 7. Everything from 0 to 6 is here, so the missing one is the top of the range, 7.

Constraints

  • 1 <= n == nums.length <= 10^4
  • 0 <= nums[i] <= n
  • All values in nums are different.

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

  • Confusing Bib NumbersVerily · ONSITE INTERVIEW
  • Plus OneDruva · ONSITE INTERVIEW
  • Rotate a Flat Image ClockwiseGoogle · ONSITE INTERVIEWGoogle interview questions
  • Matrix MultiplicationeBay · ONSITE INTERVIEWeBay interview questions
  • Maximum Product of Three IntegersPelatro · ONSITE INTERVIEW
  • Exact-Sixty Dice Game ValueJane Street · ONSITE INTERVIEWJane Street interview questions
  • Find the Missing Number from 1 to nHyperVerge · ONSITE INTERVIEW
  • Alternating Index Square SumAccenture · ONSITE INTERVIEWAccenture interview questions
  • Moving Cost by Volume and CategoryWayfair · ONSITE INTERVIEWWayfair interview questions
  • Add One to a Number Represented as DigitsOracle · ONSITE INTERVIEWOracle interview questions

Capital One interview experiences

  • Capital One Coding OA Questions: 3 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
All Capital One interview questionsSee Capital One hiring insights
Saved
class Solution {
    public int missingNumber(int[] nums) {
        // Write your code here.
    }
}
Checking account…