Đề bài
Xem bản dịchReturn 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.
Ràng buộc
0 ≤ length ≤ 100,000
Ví dụ
Ví dụ 1
Đầu vào:
numbers = [3, 1, 3, 2, 1]
Kết quả mong đợi:
expected = [3, 1, 2]
Đầu vào:
std::vector<long long> numbers = {3, 1, 3, 2, 1};
Kết quả mong đợi:
std::vector<long long> expected = {3, 1, 2};
Đầu vào:
long[] numbers = new long[] {3, 1, 3, 2, 1};
Kết quả mong đợi:
long[] expected = new long[] {3, 1, 2};
Giải thích
Keep 3, 1, then 2; the later 3 and 1 are dropped: [3, 1, 2].
Ví dụ 2
Đầu vào:
numbers = [7, 7, 7]
Kết quả mong đợi:
expected = [7]
Đầu vào:
std::vector<long long> numbers = {7, 7, 7};
Kết quả mong đợi:
std::vector<long long> expected = {7};
Đầu vào:
long[] numbers = new long[] {7, 7, 7};
Kết quả mong đợi:
long[] expected = new long[] {7};
Giải thích
Only the first 7 stays: [7].
Tham khảo
Thử thách này đã được điều chỉnh cho CodeUtility. Hãy làm theo đề bài và các ràng buộc ở trên.