Stores current index in arr2 [ ] for every element of arr1 [ ] . Initially all values are considered 0. Here current index is the index before which all elements are considered as part of output .
int index2 [ ] = new int [ n1 ] ; while ( k > 0 ) {