Remove the Duplicates
Time limit1sMemory limit128 MB
For each test case, collapse every run of consecutive equal numbers into a single value and print the result.
- Level
Easy2 of 10
- Topics
- Array, Implementation
- Solved
- No attempts yet
Problem
Al's Chocolate Mango Company runs a website where visitors can guess how many chocolate mangoes are inside a 2d jar. A visitor picks a number from to and presses the "Submit" button. Because the server often responds slowly, impatient visitors mash the "Submit" button several times, which causes the same number to be submitted many times in a row.
Help the ACM staff collapse each run of consecutive duplicate submissions into a single value, recovering the original intended sequence.
Input
The input consists of several test cases. Each line begins with an integer (), followed by integers, each between and inclusive. These numbers are the submitted values, in the order the visitor pressed them.
The last line contains a single , marking the end of the input.
Output
For each test case, print one line containing the submissions after collapsing every run of consecutive equal numbers into one, separated by single spaces. At the end of each line, print a single space followed by a $ character.