Function to implement merging of arr [ ]
static ArrayList < Integer > merge ( ArrayList < Integer > x , ArrayList < Integer > y ) { for ( Integer i : y ) { if ( x . get ( x . size ( ) - 1 ) > i ) x . add ( i ) ; } return x ; }