#K11401. Remove Consecutive Repeated Words
Remove Consecutive Repeated Words
Remove Consecutive Repeated Words
You are given a sentence containing words separated by spaces. Your task is to remove consecutive repeated words, keeping only the first occurrence of each group of identical words.
For example, if the input is "this is is a test test sentence"
, then the output should be "this is a test sentence"
.
This problem requires simple string manipulation and careful comparison between adjacent words.
inputFormat
A single line of text representing a sentence. The sentence consists of words separated by spaces and will contain at least one word. Input is provided via standard input (stdin).
outputFormat
A single modified sentence where all consecutive repeated words have been removed. The result should be printed to standard output (stdout).## sample
this is is a test test sentence
this is a test sentence