HARMAN interview question

Merge and sort the 2D array in topological order