Skip to main content
mediumNeetCode 150

Kth Largest Element in an Array

Find kth largest element in array Example: [3,2,1,5,6,4], k=2 => 5

I never sort the whole array. A size-k heap keeps the biggest k, or one quickselect partition lands straight on the answer.

Arrays & HashingHeap / Priority QueueBinary Search

Meet Coco

Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Typing with Coco is free when you sign in, up to a daily limit. Talking with her out loud comes with the $79 pack. Anyone can open the editor and run their code.

1Kth Largest Elementmedium
Based onLeetCode