Einfach 0 gelöst 0% Erfolgsquote

Remove Duplicates

Keep only the first occurrence of each value.

Return the list with repeated values removed, keeping the first occurrence of each value in its original order.

Implement remove_duplicates(numbers).

Input

numbers: The list of integers.

Output

Return the list without duplicates.

Einschränkungen

0 ≤ length ≤ 100,000

Beispiele

Beispiel 1
Eingabe:
numbers = [3, 1, 3, 2, 1]

Erwartete Ausgabe:
expected = [3, 1, 2]
Eingabe:
std::vector<long long> numbers = {3, 1, 3, 2, 1};

Erwartete Ausgabe:
std::vector<long long> expected = {3, 1, 2};
Eingabe:
long[] numbers = new long[] {3, 1, 3, 2, 1};

Erwartete Ausgabe:
long[] expected = new long[] {3, 1, 2};

Erläuterung

Keep 3, 1, then 2; the later 3 and 1 are dropped: [3, 1, 2].

Beispiel 2
Eingabe:
numbers = [7, 7, 7]

Erwartete Ausgabe:
expected = [7]
Eingabe:
std::vector<long long> numbers = {7, 7, 7};

Erwartete Ausgabe:
std::vector<long long> expected = {7};
Eingabe:
long[] numbers = new long[] {7, 7, 7};

Erwartete Ausgabe:
long[] expected = new long[] {7};

Erläuterung

Only the first 7 stays: [7].

Referenzen

Diese Aufgabe wurde für CodeUtility angepasst. Beachte die oben genannten Vorgaben und Einschränkungen.

Von anderen lernen

Community-Lösungen

Noch keine veröffentlichten Lösungen. Löse die Aufgabe und teile als Erster eine Lösung.