Loading...
Loading...
Loading...
A canteen machine logged the order numbers of every snack sold, with repeats. The manager wants each snack number once, in the order it was first sold.
Example
Input
8 4 2 4 7 2 9 7 4
Output
4 2 7 9
Later copies of 4, 2 and 7 are dropped.
Try the problem first. Open one hint at a time.
Keep a second array unique and a count size of how many values it holds.
For each number, search unique[0..size-1]; add it only if it is not there yet.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor