Sequence conversion -


could please me understand problem:

convert input sequence of n (1 ≤ n ≤ 20) input numbers subsequences of same numbers replaced first numbers of subsequences. each input number in range [1, 2 000 000 000].

for example, input sequence 1 2 2 3 1 1 1 4 4 converted 1 2 3 1 4.

input: first, number t of test cases given. each test case specified using 2 lines. first 1 contains number n , second 1 contains numbers of sequence.

output: converted sequence. result each test case should printed in separate line.

for example, input sequence 1 2 2 3 1 1 1 4 4 converted 1 2 3 1 4.

it looks idea remove duplicate numbers occur adjacent each other when creating output.

you can keeping state variable recording previous value was. when new value, compare state value. if it's same, skip. if different, output , update state variable. remember initialize state variable value not found in input stream (e.g. -1 should work in case).


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -