</>
ShikshaCSLearn. Code. Grow.
šŸ”
ā˜• Support Us
ShikshaCS›Practice Problems
DSAEasyArraysHashing

Find the Duplicate Number in an Array

šŸ“‹ Problem

Given an array of n+1 integers where each value is between 1 and n, find the one duplicate number.

🧭 Approach

Use a hash set (or a boolean 'seen' array). Go through the array once — for each number, check if it's already in the set. If yes, that's your duplicate. If no, add it to the set and continue. This avoids the O(n²) cost of comparing every pair.

← Back to all Problems