Arista Networks interview question
Find the one value missing from a range of distinct numbers
- Company:
- Arista Networks
- Type:
- Coding
- Difficulty:
- Easy
- Reported:
- October 4, 2026
Problem
An array nums contains n distinct integers taken from the range 0 to n inclusive, so exactly one value in that range is missing. Return the missing value. Aim for O(n) time and O(1) extra space.
Example 1
Input: nums = [4, 0, 1, 3]
Output: 2
The range is 0 to 4 and only 2 is absent.
Example 2
Input: nums = [0, 1]
Output: 2
The range is 0 to 2, so the missing value is the top of the range.
Constraints
1 <= n <= 10^40 <= nums[i] <= n, all values distinct.
Reported by candidates or drawn from publicly available sources, and rewritten in our own words. Pathwise Prep does not publish confidential assessment content. Report a concern