Problem
You get an array of integers nums and an integer k. Return the kth largest item in nums.
The kth largest item is the item at position k when you sort nums from the largest to the smallest. Equal values count as separate items.
Example 1
- Input:
- nums = [7,2,9,4,5], k = 2
- Output:
- 7
- Explanation:
- The largest item is 9, and the 2nd largest item is 7.
Example 2
- Input:
- nums = [6,6,3,8,8,1], k = 3
- Output:
- 6
- Explanation:
- From the largest to the smallest, the items are
[8, 8, 6, 6, 3, 1]. The item at position 3 is 6.
Constraints
- 1 <= k <= nums.length <= 10^5
- -10^4 <= nums[i] <= 10^4
Follow-up
Find a solution that does not sort all of nums.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- K Closest Points to Origin
Coding · Array · Divide and Conquer · Geometry
- Top K Frequent Elements
Coding · Array · Bucket Sort · Counting
- Majority Element
Coding · Array · Boyer–Moore Majority Vote Algorithm · Counting
- High Five
Coding · Array · Hash Table · Heap (Priority Queue)
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 3 records
LinkedIn
Leetcode 215. Kth Largest Element in an Array
Reported Sep 7, 2026 · 5 source reports
MID_LEVEL, SENIOR
Source snapshot: Nov 12, 2026
View sourceMeta
Leetcode 215. Kth Largest Element in an Array
Reported Feb 10, 2026 · 46 source reports
MANAGER, MID_LEVEL, PRINCIPAL, SENIOR, STAFF
Source snapshot: Nov 12, 2026
View sourceSalesforce
Leetcode 215. Kth Largest Element in an Array
Reported Nov 23, 2025 · 2 source reports
MID_LEVEL, STAFF
Source snapshot: Nov 12, 2026
View source