First Unique Values
When data comes from different sources, duplicates often appear in a list: for example, the same organization may show up more than once. Write a function dedup that returns the unique values from items while keeping the order of their first appearance. If an element has already been seen, do not add it again. An empty list should stay empty.
Примеры
Ввод
[1, 2, 2, 3, 1, 4]Вывод
[1, 2, 3, 4]Ввод
[]Вывод
[]Ввод
["a", "b", "a", "c", "b"]Вывод
["a", "b", "c"]Нужно реализовать
def dedup(items):
Теги
arraylistssethashmap
Συνδεθείτε για να δείτε το ιστορικό υποβολών
ΣύνδεσηΣυνδεθείτε για να χρησιμοποιήσετε τον AI Mentor
ΣύνδεσηVisible tests
1
Input
[1,2,2,3,1,4]Expected
[1,2,3,4]2
Input
[]Expected
[]3
Input
["a","b","a","c","b"]Expected
["a","b","c"]4
Input
[5,5,5]Expected
[5]5
Input
[3,1,2]Expected
[3,1,2]6
Input
[1]Expected
[1]Focus radio
Paused · SomaFM · Fluid