Arrays & Hashing • Easy
Contains Duplicate
Given an integer array `nums`, return `true` if any value appears at least twice in the array, and return `false` if every element is distinct.
The Challenge
Given an integer array `nums`, return `true` if any value appears at least twice in the array, and return `false` if every element is distinct.
Pro-tip: Use a Set to keep track of seen elements. Checking for existence in a Set is O(1).
Solution.swift Tests.swift
Output
Ready to run.