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 .
let index2 = new Array ( n1 ) ; index2 . fill ( 0 ) ; while ( k > 0 ) {