Hi, I was asked two questions in my Facebook Phonescreen yesterday.
1st: was variation of
Given k sorted segments of an array, sort the array
for example:
9,10,11,2,3,4,-1,0,1
sort this:
-1,0,1,2,3,4,9,10,11
I created a list of lists.I tried to extract elements from these k segments in k lists. Then created a Priority queue of size k and in every iteration, only put k elements in the queue. Since this will be min queue, my root will have the minimum element. I will reuse the same array (provided in input) and poll from queue to my array back.
Can someone come up with anything else?
My code did not work completely, but the interviewer seemed satisfied.
Waiting for results.
Thanks and hope this helps