Information, calcul, communication
CS-119(k)
ICC-P Code pour exercice 2
This page is part of the content downloaded from ICC-P Code pour exercice 2 on Sunday, 29 June 2025, 20:43. Note that some content and any files larger than 50 MB are not downloaded.
Page content
Code:
from random import randint
def has_duplicates(l: list[int]) -> bool:
...
print(has_duplicates([])) # False
print(has_duplicates([9, 3, 2, 5, 1])) # False
print(has_duplicates([1, 1])) # True
print(has_duplicates([1, 2, 2, 3, 1, 5, 1])) # True
def find_duplicates(l: list[int]) -> list[int]:
...
print(find_duplicates([])) # []
print(find_duplicates([1, 2, 3, 5, 9])) # []
print(find_duplicates([1, 1])) # [1]
print(find_duplicates([1, 2, 2, 3, 1, 5, 1])) # [1, 2] ou [2, 1]