Remove duplicates from integers
Input
list_to_set([3, 1, 2, 3])
Output
[1, 2, 3]
Convert to a set to drop the duplicate 3, then sort to get a consistent list [1, 2, 3].
Full lesson preview
Learn how to remove duplicate items from a list by converting it to a set and returning a canonical sorted result.
Problem statement
Task
Examples
Input
list_to_set([3, 1, 2, 3])
Output
[1, 2, 3]
Convert to a set to drop the duplicate 3, then sort to get a consistent list [1, 2, 3].
Input format
Output format
Constraints
Samples
Input
[1, 1, 2, 2, 3]
Output
[1, 2, 3]
Duplicates removed and result sorted.