Kth Largest Element in an Array Problem
Kth Largest Element in an Array Problem — ExecCode Medium DSA Practice
Solve the Kth Largest Element in an Array problem on ExecCode. Free online medium DSA practice in Heap. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Given an integer array nums and an integer k, return the kᵗʰ largest element in the array. Note that it is the kᵗʰ largest element in sorted order, not the kᵗʰ distinct element.
Examples
Input nums = [3, 2, 1, 5, 6, 4], k = 2; Output 5. Input nums = [3, 2, 3, 1, 2, 4, 5, 5, 6], k = 4; Output 4. Input nums = [7, 6, 5, 4, 3, 2, 1], k = 1; Output 7
Constraints
1 ≤ k ≤ nums.length ≤ 10⁴ -10⁴ ≤ nums[i] ≤ 10⁴
Practice Kth Largest Element in an Array free on ExecCode. Browse DSA problems, topic map, and placement guides.