My python code:
In this im using hashmap and comparing before inserting the element of the array into the hashmap and return True if the element is already present…
class Solution(object):
def containsDuplicate(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
map={}
for i in range(len(nums)):
if nums[i] in map:
return True
map[i]=nums[i]
return False
This code is giving me wrong answer for [3,3] i.e. false but expected output is true
i tried doing dry run for this but im getting true according to my code
Please tell me if im making any mistake
New contributor
Shirish Aul is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.