Last active
May 5, 2019 19:23
-
-
Save repen/681bf1905c761eeca683ced85bbe6789 to your computer and use it in GitHub Desktop.
Search dublicate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arr = [1,2,1,5,2,1,3,2,4] | |
# arr = [1,2,3,4] | |
class MyException(ValueError): | |
pass | |
def dublicate(arr, repeat = []): | |
if not arr: | |
raise MyException("Exception None dublicate") | |
elif arr[0] in repeat: | |
return arr[0] | |
else: | |
if arr.count(arr[0]) >= 2: | |
repeat.append(arr[0]) | |
return dublicate(arr[1:]) | |
res = dublicate(arr) | |
print(res) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment