Problema
Mostra traduzioneReturn 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.
Vincoli
0 ≤ length ≤ 100,000
Esempi
Esempio 1
Input:
numbers = [3, 1, 3, 2, 1]
Output atteso:
expected = [3, 1, 2]
Input:
std::vector<long long> numbers = {3, 1, 3, 2, 1};
Output atteso:
std::vector<long long> expected = {3, 1, 2};
Input:
long[] numbers = new long[] {3, 1, 3, 2, 1};
Output atteso:
long[] expected = new long[] {3, 1, 2};
Spiegazione
Keep 3, 1, then 2; the later 3 and 1 are dropped: [3, 1, 2].
Esempio 2
Input:
numbers = [7, 7, 7]
Output atteso:
expected = [7]
Input:
std::vector<long long> numbers = {7, 7, 7};
Output atteso:
std::vector<long long> expected = {7};
Input:
long[] numbers = new long[] {7, 7, 7};
Output atteso:
long[] expected = new long[] {7};
Spiegazione
Only the first 7 stays: [7].
Riferimenti
Questa sfida è adattata per CodeUtility. Segui la traccia e i vincoli sopra.