DSA · Hashing · #20
Contains Duplicate
Module 23 · difficulty 1/5·⏱ 30:00starts on first keystroke
Given an integer array `nums`, return `true` if any value appears at least twice in the array, and `false` if every element is distinct.
Examples
nums = [1,2,3,1]→truenums = [1,2,3,4]→falsenums = [1,1,1,3,3,4,3,2,4,2]→true
Stuck? Reveal an animated walkthrough of the approach.
Constraints
- · 1 <= nums.length <= 10^5
- · -10^9 <= nums[i] <= 10^9
Session phases
A · Clarify
B · Approach
C · Complexity
D · Edges
E · Code
F · Tradeoff
G · Score
Phase A — Clarify
Ask questions about input bounds, types, and edge constraints.
Ask the coach clarifying questions about the problem.
When you've covered this phase, advance to the next.