問題
翻訳を表示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用に調整されています。上記の説明と制約に従ってください。