Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Before
- def contains_duplicate(array):
- for i in range(len(array)):
- for j in range(i):
- if array[i] == array[j]:
- return True
- return False
- # After
- def contains_duplicate(array):
- return any(
- array[i] == array[j]
- for i in range(len(array))
- for j in range(i)
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement