Skip to content

Practice Contains Duplicate

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#217
LeetCode Problem

Contains Duplicate

Problem Statement

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.

Source: Contains Duplicate on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,2,3,1]
Output
true

# Example 2

Input
nums = [1,2,3,4]
Output
false

# Example 3

Input
nums = [1,1,1,3,3,4,3,2,4,2]
Output
true

Constraints

1 <= nums.length <= 10^5
-10^9 <= nums[i] <= 10^9

Related LeetCode Problems

Practice more problems similar to Contains Duplicate.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.