ArrayList v1 = new ArrayList ( ) ; to insert even values ArrayList v2 = new ArrayList ( ) ; to insert odd values
for ( int j = 0 ; j < n ; j ++ ) if ( arr [ j ] % 2 == 0 ) v1 . Add ( arr [ j ] ) ; else v2 . Add ( arr [ j ] ) ; int index = 0 , i = 0 , k = 0 ; bool flag = false ;