Array Contains Duplicate - aloalgo

Array Contains Duplicate

Very Easy

You are given an integer array nums.

Your task is to determine whether any value appears more than once in the array.

You may assume that:

  • The array can be empty, in which case there are no duplicates.

Return true if any duplicate exists, otherwise return false.

Example 1

Input
[1, 2, 3, 1]
Output
True
Explanation:

The value 1 appears twice, so we return true.

Example 2

Input
[1, 2, 3, 4]
Output
False
Explanation:

All elements are distinct, so we return false.

Example 3

Input
[1, 1, 1, 3, 3, 4, 3, 2, 4, 2]
Output
True
Explanation:

The value 3 appears three times, so we return true.

Loading...
Input
[1, 2, 3, 1]
Output
True

Hello! I am your ✨ AI assistant. I can provide you hints, explanations, give feedback on your code, and more. Just ask me anything related to the problem you're working on!