Facebook Pixel

Contains Duplicate

Given an array of integers, determine if it contains any duplicate values. Return true if at least one value appears more than once, false otherwise.

Input

  • nums: an array of integers

Output

A boolean - true if the array contains duplicates, false otherwise

Examples

Example 1:

Input: nums = [1, 2, 3, 4]

Output: false

Explanation: All elements are unique.

Example 2:

Input: nums = [1, 2, 3, 1]

Output: true

Explanation: The value 1 appears twice.

Example 3:

Input: nums = [5, 5, 5]

Output: true

Explanation: The value 5 appears three times.

Try It Yourself

Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro