LeetCode - Blind 75 - Contains Duplicate

The Problem 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. Example Input: nums = [1,2,3,1] Output: true Explanation: The element 1 occurs at indices 0 and 3. Follow-up: Can you come up with an algorithm that has less than O(NlogN) time complexity? Brute Force Solution func containsDuplicate(_ nums: [Int]) -> Bool { var nums = nums let N = nums....

October 26, 2024 · 2 min · Dmytro Chumakov