Home
Topics
Practice
Roadmap
DSA Tracker
Code Editor
Tech Blogs
More
Sign in
Get started
Loading question...
Feedback
Find the Duplicate Number
Medium
00:00
0 users online
Share
Description
Solution
Submissions
Discussion
Given an array of n+1 integers where each integer is between 1 and n, find the duplicate number.
Sample Input:
[1,3,4,2,2]
Sample Output:
2
Hints
Hint 1
Use Floyd's Tortoise and Hare algorithm
Hint 2
Treat array as linked list where value points to index
Hint 3
Find intersection point and then find cycle entrance
Code Editor
Reset
Run
Save
Loading...