Advertisement
EconomicSerg

Find Duplicate Number

Jan 21st, 2021
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. # Find the duplicate number
  2. # Script from Joma Tech on YT
  3.  
  4. def findDuplicate(nums):
  5.     nums.sort()
  6.     for i in range(1, len(nums)):
  7.         if nums[i] == nums[i - 1]:
  8.             return nums[i]
  9.  
  10.  
  11. print(findDuplicate([3, 1, 3, 4, 2]))
  12.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement