Keep First Occurrences

Sometimes you need to remove duplicates from a list without sorting it, because the original order matters. The function remove_duplicates receives a list array. Keep only the first appearance of each element and skip all later repeats. Return a new list in the order where the elements first appeared.

Примеры

Ввод
[[1, 1, 1, 2, 2, 3, 4, 4, 5]]
Вывод
[1, 2, 3, 4, 5]
Ввод
[["hey", "hello", "hello", "car", "house", "house"]]
Вывод
["hey", "hello", "car", "house"]
Ввод
[[1, 2, 3]]
Вывод
[1, 2, 3]

Нужно реализовать

def remove_duplicates(array: list) -> list:

Теги

arrayset
PostgreSQLv16

Hier verschijnt het resultaat van je code

Visible tests
1
Input
[1,1,1,2,2,3,4,4,5]
Expected[1,2,3,4,5]
2
Input
["hey","hello","hello","car","house","house"]
Expected["hey","hello","car","house"]
3
Input
[1,2,3]
Expected[1,2,3]
4
Input
[7,7,7]
Expected[7]
5
Input
[1,2,3,1]
Expected[1,2,3]
6
Input
[2,2,2,3,3,4,5,5,6]
Expected[2,3,4,5,6]
Focus radio
Paused · SomaFM · Fluid