ntree.ai
ntree.aiContains Duplicate

Contains Duplicate

easysolvedattempted

Given an array of integers nums, return true if any element appears more than once, and false if all the elements are different.

Example 1:

Input:  nums = [4, 7, 1, 9, 7]
Output: true
Explanation: 7 appears twice.

Example 2:

Input:  nums = [4, 7, 1, 9]
Output: false

Constraints:

  • 1 <= length of nums <= 10^5
  • -10^9 <= nums[i] <= 10^9
def containsDuplicate(nums: list[int]) -> bool:
pass
 

Press Visualise to step through your code.