Sort the array in descending order, return element at index k - 1.
Sorting takes . But you only need the kth largest, not the full sorted order.
Can you find the answer faster by doing less work?
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
The trap
Sort the array in descending order, return element at index k - 1.
Sorting takes . But you only need the kth largest, not the full sorted order.
Can you find the answer faster by doing less work?