You have given an array from which we need to remove duplicates.
Rules:
First or immediate duplicates gets removed first.
Array contains natural numbers
a[i]>0 for i>=0no. of elements in the array is greater than 1 i.e.
n>1
e.g.
{1,2,3,4,5,5,4,6,6,7,8}=> {1,2,3,7,8}
{1,2,3,3,4,5,6,7,7,8} => {1,2,4,5,6,8}
{1,1,3,3,4,4,6,6}=>{}
{4,2,6,8,3,1,1,3,8,6,2,4}=>{}
{6,6,6,1}=>{6,1}
Only adjacent duplicate elements like [1, 2, 2, 1] are removed, but not [1, 2, 1, 2]. This process is repeated until no further modifications are made.
For winning criteria is the one which gives the fastest result.
{6,1}?6is a duplicate. Then,{1,2,3,4,5,5,4,6,6,7,8}should output{1,2,3,4,5,6,7,8}as well. \$\endgroup\$