#K69027. Consecutive Duplicate Remover
Consecutive Duplicate Remover
Consecutive Duplicate Remover
Problem Description:
You are given a list of integers. Your task is to remove consecutive duplicate elements from the list while preserving the original order of the elements.
For example, if the list contains consecutive repeated numbers, only the first occurrence in each group should be kept. Non consecutive duplicates should not be removed.
Note: The solution should read input from stdin
and produce output to stdout
as specified in the Input and Output sections.
inputFormat
Input Format:
The first line contains an integer n representing the number of elements in the list.
The second line contains n space-separated integers.
Example:
10 1 2 2 3 3 3 4 4 5 1
outputFormat
Output Format:
Output the list after removing consecutive duplicate elements. The numbers should be output as space-separated integers on a single line.
Example:
1 2 3 4 5 1## sample
10
1 2 2 3 3 3 4 4 5 1
1 2 3 4 5 1