FaceBook Phone Screen(Menlo Park 5YOE)
Anonymous User
870

Hi, I was asked two questions in my Facebook Phonescreen yesterday.
1st: was variation of

  1. Find Duplicate File in System(VERY close to this though)
    2nd was this:

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

Comments (5)