Push the index in the indices [ A [ i ] ] and also store the numbers in set to get the numbers present in input array
for ( int i = 0 ; i < N ; i ++ ) { indices [ arr [ i ] ] . push_back ( i ) ; elements . insert ( arr [ i ] ) ; }