arrow_back Back to Challenges

#287 Find the Duplicate Number

Medium Acceptance 0%
description

Problem Description

Given an array of integers `nums` containing `n + 1` integers where each integer is in the range `[1, n]` inclusive. There is only one repeated number in `nums`, return this repeated number. You must solve the problem without modifying the array `nums` and uses only constant extra space.

checklist Constraints

1 <= n <= 10^5
nums.length == n + 1
1 <= nums[i] <= n
All the integers in nums appear only once except for precisely one integer which appears two or more times.

science Examples

Case #1

In: nums = [1,3,4,2,2]
Out: 2

Case #2

In: nums = [3,1,3,4,2]
Out: 3

Mastery Tags

Arrays Binary Search Two Pointers

Hiring Companies

Amazon Google Microsoft
code

Integrated IDE

code_blocks
Coding
psychology
Aptitude