FastPrepFind All Repeated Numbers
Problems/Find All Repeated Numbers

Find All Repeated Numbers

Nutanix logoNutanix● MediumINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A report published in September 2017 describes a Nutanix on-campus drive for interns. In the first interview round, the author listed questions that other candidates in the same round were asked, so this one is second-hand. It was not asked to the author. The task was to report which values show up more than once in an array of length n. The values run from 0 to n - 1, and several values can repeat. The author linked a well-known version of the exercise that aims for linear time and constant extra space.

The report gives no examples, limits or output format. Here we chose the following. The input is one integer array and the answer is an integer array. A value can appear any number of times. Each repeated value is listed once, in increasing order. The answer is empty when nothing repeats. The length is between 1 and 10^5. The linear-time, constant-space target is kept as a goal, and the array may be changed while working. The tests check only the returned values.

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

You are given an integer array nums of length n. Every value in nums is between 0 and n - 1, inclusive. A value can appear any number of times, and several different values can repeat.

Return every value that appears at least twice in nums. List each such value once, in increasing order. If no value repeats, return an empty array.

Goal: aim for O(n) time and O(1) extra space, not counting the returned array. You may change nums while you work. The judge checks only the returned array; it does not measure the extra space you use.

Function

findRepeatedNumbers(nums: int[]) → int[]

Examples

Example 1

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

Here n = 8, so every value is between 0 and 7. The value 1 appears three times and 3 appears twice. The values 0, 4 and 5 appear once, and 2, 6 and 7 do not appear. Each repeated value is listed once, from smallest to largest: [1,3].

Example 2

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

Every value from 0 to 3 appears exactly once, so no value repeats and the answer is an empty array.

Example 3

nums = [4,0,4,0,2]return = [0,4]

The value 4 appears first at index 0 and again at index 2, and 0 appears at indices 1 and 3. Both repeat. The answer lists them in increasing order, [0,4], even though the second 4 comes before the second 0.

Constraints

  • 1 <= n == nums.length <= 10^5
  • 0 <= nums[i] <= n - 1

More Nutanix Onsite Interview questions

  • Design Hit CounterONSITE INTERVIEW · Seen Oct 2026
  • Peak Process MemoryONSITE INTERVIEW · Seen Aug 2026
  • Minimum Operations to Transform ArrayONSITE INTERVIEW · Seen Jun 2026
  • Count Connected Components in an Undirected GraphONSITE INTERVIEW · Seen Aug 2025
  • LRU CacheONSITE INTERVIEW · Seen Aug 2025
  • Running Median of a Multilevel Linked List in Level OrderONSITE INTERVIEW · Seen Aug 2025
  • Custom Array IteratorONSITE INTERVIEW · Seen Dec 2024
  • Collapse Runs of Repeated CharactersONSITE INTERVIEW · Seen Nov 2022
  • Anagram Words in a SentenceONSITE INTERVIEW · Seen Apr 2022
  • Sudoku SolverONSITE INTERVIEW · Seen Feb 2022

Similar questions at other companies

  • Random Dasher Set OperationsDoorDash · ONSITE INTERVIEWDoorDash interview questions
  • Shortest Window with Required CountsOracle · ONSITE INTERVIEWOracle interview questions
  • Count Zero Request ServersSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Filter, Sort, and Deduplicate Scheduled TasksRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Propagating Fraud DetectorAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
  • Deep Copy a Random-Pointer ListAmazon · ONSITE INTERVIEW
  • Count Subarrays with Equal Even and Odd CountsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Instant-Runoff Voting WinnerWise · ONSITE INTERVIEW
  • Sudoku Board ValidationConfluent · PHONE SCREEN · ONSITE INTERVIEWConfluent interview questions
  • Indexed Person Record QueriesGoogle · ONSITE INTERVIEWGoogle interview questions

Interview reports that mention this question

  • Nutanix Intern Debugging Round and Interviews: 25 Experiences

Nutanix interview experiences

  • Nutanix SWE Intern Phone Screens: 20 Experiences (Part 3 of 3)
  • Nutanix SWE Intern OA Questions: 16 Experiences (Part 2 of 3)
  • Nutanix U.S. SWE Intern Interviews: 54 Experiences (Part 1 of 3)
  • Nutanix SWE OA and Interviews, Level Not Reported: 9 Experiences
All Nutanix interview questionsSee Nutanix hiring insights
Saved
class Solution {
    public int[] findRepeatedNumbers(int[] nums) {
        // Write your code here.
    }
}
Checking account…