Remove Duplicates from a List
Riverbend Library logs a shelf number every time a book is returned. At closing time a porter walks the shelves in the order the returns came in, so a shelf that was hit three times still needs only one visit. The log is handed over exactly as it was recorded, repeats and all.
Task: Print each shelf number once, keeping the order in which it first appeared in the log.
Input
A single line holding between 1 and 1000 integers separated by single spaces. A number may repeat, and the repeats are not necessarily next to each other.
Output
One line holding the shelf numbers separated by single spaces, each appearing once, in the order it was first seen. Do not sort them.
Example:
Input:
1 2 2 3 1 4
Output:
1 2 3 4
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in