FastPrepThe One Repeated Number
Problems/The One Repeated Number

The One Repeated Number

Adobe logoAdobe● EasyFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: In the first live round, where three questions were written as compilable code, the candidate had to find the one integer that shows up twice in a stream where every other integer shows up once. They talked through several ideas and ended with XOR, and the interviewer pressed hard on why XOR works.

The report does not say which values the stream holds, how long it is, or how it is given. Here the n numbers come as an array holding every value from 1 to n - 1 once plus one of them a second time, with n from 2 to 10^4. The examples are our own. The XOR questions are answered in the editorial and are not judged.

The judged task matches the report at about 70%.

Numbers arrive one after another, and you are given them as the array nums in arrival order. Let n be the number of values.

The values are every whole number from 1 to n - 1, each exactly once, except that one of them arrives a second time. The two copies can be anywhere. Return the value that arrives twice.

Function

findRepeated(nums: int[]) → int

Examples

Example 1

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

There are 6 numbers, so the values are 1 to 5 with one of them twice. 5 appears at index 0 and again at index 4.

Example 2

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

There are 6 numbers, so the values are 1 to 5. 4 appears at index 1 and again at index 4; every other value appears once.

Example 3

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

The values 1 to 6 each appear once, except 3, which appears at index 1 and at index 6.

Constraints

  • 2 <= n <= 10^4, where n = nums.length
  • 1 <= nums[i] <= n - 1
  • Every value from 1 to n - 1 appears in nums, and exactly one of them appears twice.

More Adobe problems

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
All Adobe interview questionsSee Adobe hiring insights
Saved
public int findRepeated(int[] nums) {
    // Write your code here.
}
Checking account…