
'''
Given an array of integers, find if the array contains any duplicates.
Your function should return true if any value appears at least twice in
the array, and it should return false if every element is distinct.
'''

#Use a dictionary to store all numbers. If a number is seen 2nd time return immediately
#Time Complexity = O(n)   since we have a single for-loop to look at all numbers
def containsDuplicate(self, nums):
  dict = {}
  for val in nums:
    if val not in dict:  dict[val] = 1
    elif val in dict:    return True
  return False



'''
Given an array of integers, find if the array contains any duplicates.
Your function should return true if any value appears at least twice in
the array, and it should return false if every element is distinct.
'''

#Use a dictionary to store all numbers. If a number is seen 2nd time return immediately
#Time Complexity = O(n)   since we have a single for-loop to look at all numbers
def containsDuplicate(self, nums):
  dict = {}
  for num in nums:
    if num not in dict:  dict[num] = 1
    elif num   in dict:  return True
  return False


Change keyword val to num
Change keyword val to num
  
  '''
  Given an array of integers, find if the array contains any duplicates.
  Your function should return true if any value appears at least twice in
  the array, and it should return false if every element is distinct.
  '''
  
  #Use a dictionary to store all numbers. If a number is seen 2nd time return immediately
  #Time Complexity = O(n)   since we have a single for-loop to look at all numbers
  def containsDuplicate(self, nums):
    dict = {}
-   for val in nums:
+   for num in nums:
-     if val not in dict:  dict[val] = 1
+     if num not in dict:  dict[num] = 1
-     elif val in dict:    return True
+     elif num   in dict:  return True
    return False
  
  
Change keyword val to num
## Code Before:

'''
Given an array of integers, find if the array contains any duplicates.
Your function should return true if any value appears at least twice in
the array, and it should return false if every element is distinct.
'''

#Use a dictionary to store all numbers. If a number is seen 2nd time return immediately
#Time Complexity = O(n)   since we have a single for-loop to look at all numbers
def containsDuplicate(self, nums):
  dict = {}
  for val in nums:
    if val not in dict:  dict[val] = 1
    elif val in dict:    return True
  return False


## Instruction:
Change keyword val to num
## Code After:

'''
Given an array of integers, find if the array contains any duplicates.
Your function should return true if any value appears at least twice in
the array, and it should return false if every element is distinct.
'''

#Use a dictionary to store all numbers. If a number is seen 2nd time return immediately
#Time Complexity = O(n)   since we have a single for-loop to look at all numbers
def containsDuplicate(self, nums):
  dict = {}
  for num in nums:
    if num not in dict:  dict[num] = 1
    elif num   in dict:  return True
  return False

