midArrays
How do you find duplicates in an array?
Updated Apr 28, 2026
Short answer
Use hash set or sorting.
Deep explanation
Duplicates can be found using sets in O(n) or sorting in O(n log n).
Real-world example
Detecting duplicate users.
Common mistakes
- Ignoring space complexity.
Follow-up questions
- Why set?
- Alternative?