Given k sorted arrays of possibly different sizes, merge them and print the sorted output. Input Size : N<=100
Created 2 years ago
128
Views
1
Comments
I hope its a UI issue with result
Given k sorted arrays of possibly different sizes, merge them and print the sorted output.
Input Size : N<=100
Example:
INPUT
k = 3
1 3
2 4 6
0 9 10 11
OUTPUT
0 1 2 3 4 6 9 10 11
Code :
let one = userInput[0].split(" ")
let two = userInput[1].split(" ")
let three = userInput[2].split(" ")
// let str2 =userInput[1].split("").sort();
let newArr=one.concat(two,three).sort((a,b)=> {return a - b})
console.log(newArr.join(" "))
but testcase fails:
Input :
2
1 5
-5 11
Expected result : -5 1 5 11.
my result : -5 1 2 5 11.
Please rectify if my code is wrong