Remove duplicates from a list of integers
Input
[3, 1, 2, 3]
Output
[1, 2, 3]
Convert the list to a set to get {1,2,3} then return it as a sorted list [1,2,3].
Full lesson preview
Learn how to create a set from a collection to get unique items and return them in a deterministic order.
Problem statement
Task
Examples
Input
[3, 1, 2, 3]
Output
[1, 2, 3]
Convert the list to a set to get {1,2,3} then return it as a sorted list [1,2,3].
Input format
Output format
Constraints
Samples
Input
[3, 1, 2, 3]
Output
[1, 2, 3]
Duplicates removed, then sorted.