beginnerArrays & Two Pointers
Contains duplicate
Given an array of integers, return true if any value appears at least twice, otherwise false. Explain the cost of your approach before you optimise it.
Examples
input nums = [4, 9, 1, 9]
output true
9 appears at index 1 and index 3.
input nums = [3, 1, 4, 2]
output false
Every value is distinct.
Hints
Try the problem first. Hints are revealed one at a time so you keep thinking.
Solution
The written approach, complexity analysis and follow-ups stay hidden until you ask for them.