ASAPUtils Logo ASAPUtils
Week 1

Contains Duplicate

Contains Duplicate solved with a hash set in one pass, with C++ and JavaScript code, a step-by-step visualizer, and the sorting and brute-force alternatives compared honestly.

The problem

Given an integer array, return true if any value appears at least twice, and false if every element is distinct.

nums = [1, 2, 3, 1] -> true nums = [1, 2, 3, 4] -> false

Related Problems