Relevel Question

1 posts Mon, Jan 17, 2022 at 08:33 AM in SRMs

You have integer array of length n ([1 2 1 2 1 3 1 3]).Remove all occurance of 1(array become [2 2 3 3]).Now you can append this resulting array to initial array , any number of time ([1 2 1 2 1 3 1 3 2 2 3 3]).

Given a resulting array print the initial array
eg.
input
1 2 1 2 1 3 1 3 2 2 3 3 2 2 3 3

output:
1 2 1 2 1 3 1 3

if no initial array possible print -1
if multiple ans possible print lexicographically smaller array.

View: Threaded  |  Flat
+0
Sign In or Register to comment.