Insert the incremented element at that index
if ( ! mp . has ( sol [ idx ] ) ) mp . set ( sol [ idx ] , new Set ( ) ) x = mp . get ( sol [ idx ] ) ; x . add ( idx ) ; mp . set ( sol [ idx ] , x ) ; x = mp . get ( sol [ i ] ) ; x . add ( i ) ; mp . set ( sol [ i ] , x ) ; } }