DSA Trainer

Contains Duplicate

SetEasy

Step 1 of 8 · Understand

1. Understand the problem

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.

Input

An array of integers `nums`.

Output

A boolean. `true` if any number appears at least twice, `false` if all numbers are distinct.

Examples

input → nums = [1, 2, 3, 1]
output → true
1 appears at index 0 and index 3.
input → nums = [1, 2, 3, 4]
output → false
All values are different.
input → nums = [1, 1, 1, 3, 3, 4, 3, 2, 4, 2]
output → true
Multiple values repeat.

Write your solution above and hit Run tests. Results and tips appear here.