Update indices of X , Y , Z ;
for ( int i = 0 ; i < n ; i ++ ) { if ( mp . ContainsKey ( s [ i ] ) ) { mp [ s [ i ] ] . Add ( i ) ; } else { mp [ s [ i ] ] = new List < int > ( ) ; mp [ s [ i ] ] . Add ( i ) ; } }