Amazon interview question

leetcode topological sort, quick select