Build a lightweight version of the Unix uniq utility.
You will receive a sequence of strings — n lines total. Print them back in the same order, except that whenever the same string repeats in consecutive lines (a run), you keep only the first line of that run and drop the rest.
Key rules:
"Apple" and "apple" count as different strings.n
line_1
line_2
...
line_n
0 <= n <= 1000000 <= len(line_i) <= 1000Print the filtered lines — one per line — to standard output.
Input:
7
apple
apple
banana
banana
banana
apple
apple
Output:
apple
banana
apple
Explanation: The first two "apple" lines form a run (only the first kept). The three "banana" lines form another run (only the first kept). The final two "apple" lines are a new run (again, only the first kept).
Input:
5
a
A
A
a
a
Output:
a
A
a
Explanation: "a" and "A" are different because the comparison is case‑sensitive. The run "A", "A" collapses to a single "A", and the trailing "a", "a" collapses to a single "a".