awelgorithms

Contains Duplicate: the skills you need first

Updated

LeetCode · easy · hash sets. Insert as you scan. A failed insert, or a contains-hit, is the duplicate.

open on LeetCode

Skills this problem builds on

Stuck on Contains Duplicate? It is usually one of these. Get each one solid and the solution stops being a trick.

  1. Detect a duplicate with a seen-set
  2. Insert one value into a set
  3. Return early on a set hit
check which ones you have 10 minutes, free, no account.

More hash sets problems