217. Contains Duplicate
Leetcode Blind 75
22th June 2022 ~ Dion Pinto
Description
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. (Problem)
Code (Python)
class Solution:
def containsDuplicate(self, nums: List[int]) -> bool:
d={}
for i in nums:
if(i in d):
d[i]+=1
if(d[i]>1):return True
else:
d[i]=1
return False
Time Complexity => o(n)
Space Complexity => o(n)