Условие
Показать перевод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.
Ограничения
0 ≤ length ≤ 100,000
Примеры
Пример 1
Ввод:
numbers = [3, 1, 3, 2, 1]
Ожидаемый вывод:
expected = [3, 1, 2]
Ввод:
std::vector<long long> numbers = {3, 1, 3, 2, 1};
Ожидаемый вывод:
std::vector<long long> expected = {3, 1, 2};
Ввод:
long[] numbers = new long[] {3, 1, 3, 2, 1};
Ожидаемый вывод:
long[] expected = new long[] {3, 1, 2};
Пояснение
Keep 3, 1, then 2; the later 3 and 1 are dropped: [3, 1, 2].
Пример 2
Ввод:
numbers = [7, 7, 7]
Ожидаемый вывод:
expected = [7]
Ввод:
std::vector<long long> numbers = {7, 7, 7};
Ожидаемый вывод:
std::vector<long long> expected = {7};
Ввод:
long[] numbers = new long[] {7, 7, 7};
Ожидаемый вывод:
long[] expected = new long[] {7};
Пояснение
Only the first 7 stays: [7].
Ссылки
Это задание адаптировано для CodeUtility. Следуйте условию и ограничениям выше.