← Practice · Heap
Kth Largest Element in an Array Medium
Given an integer array nums and an integer k, return the kth largest element in sorted order (duplicates count separately, so it is not the kth distinct value).
Examples
nums=[3,2,1,5,6,4], k=2 -> 5nums=[3,2,3,1,2,4,5,5,6], k=4 -> 4
Define a function named findKthLargest in JavaScript.
00:00
JavaScript · Tab indents · Ctrl/⌘+Enter runs the tests