#K14011. Smallest Flower Lineup
Smallest Flower Lineup
Smallest Flower Lineup
You are given a string S
consisting of uppercase English letters, where each letter represents the color of a flower arranged in a line. Your task is to remove all consecutive duplicate characters from the string and output the resulting string.
More formally, for a given string \(S\), construct a new string \(T\) by scanning \(S\) from left to right and keeping the first occurrence of any contiguous block of identical characters. That is, if one or more identical characters occur consecutively in \(S\), only the first one is included in \(T\). There is no reordering of characters.
For example, for \(S = \texttt{BACCDBE}\), the answer is \(T = \texttt{BACDBE}\), because only the first character of each block is retained.
This problem requires you to process multiple test cases efficiently, even when the input size is large (up to \(10^5\) characters per test case).
inputFormat
The input begins with an integer \(T\) (\(1 \le T \le 100\)) on the first line, which represents the number of test cases. Each of the following \(T\) lines contains a string \(S\) composed of uppercase English letters. Note that \(S\) may be empty.
outputFormat
For each test case, output a single line containing the string after removing all consecutive duplicate characters.
## sample3
BACCDBE
ABBCCA
ABC
BACDBE
ABCA
ABC
</p>