If the i - th index is still not present in its correct position , store the index
if ( arr [ i ] != i ) { pos . push_back ( i ) ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] != i ) { int pos1 = i , pos2 = arr [ i ] ; int pos3 = arr [ arr [ i ] ] ;