Driver program to test above functions
var arr = [ [ 2 , 6 , 12 , 34 ] , [ 1 , 9 , 20 , 1000 ] , [ 23 , 34 , 90 , 2000 ] ] ; var k = 4 ; var n = 3 ; var output = Array ( n * k ) . fill ( 0 ) ; mergeKArrays ( arr , n , output ) ; document . write ( " " ) ; printArray ( output , n * k ) ;