Hello coders, In this article, I am going to write another solution for another Leetcode Problem that is ” Contains Duplicate Leetcode Solution “.
Given an integer array
true if any value appears at least twice in the array, and return
false if every element is distinct.
Input: nums = [1,2,3,1] Output: true
Input: nums = [1,2,3,4] Output: false
Input: nums = [1,1,1,3,3,4,3,2,4,2] Output: true
Contains Duplicate Leetcode Solution in python
#Contains Duplicate Leetcode Solution in python class Solution: def containsDuplicate(self, nums: List[int]) -> bool: if len(set(nums))<len(nums): return 1 else: return 0 #Contains Duplicate Leetcode Solution in python
Disclaimer: This problem(Contains Duplicate Leetcode solution) is originally created by Leetcode. Codesagar only provides a solution for it. This solution is only for Educational and learning purposes.