Amazon interview question

FInd the kth largest element in an array.

Interview Answer

Anonymous

Mar 16, 2016

Solution 1:- sorting (Merge sort) then print element. complexity: Time O(nlogn) Space: O(n) Solution 2: create a min heap with K size complexity Time O(nlogk) space: O(k)