Skip to content

Commit dbd6875

Browse files
committed
Time: 56 ms (35.29%), Space: 57.1 MB (16.24%) - LeetHub
1 parent bfb1d18 commit dbd6875

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public int findKthLargest(int[] nums, int k) {
3+
PriorityQueue<Integer> pq = new PriorityQueue<>();
4+
for (int val : nums) {
5+
pq.offer(val);
6+
if (pq.size() > k) pq.poll();
7+
}
8+
return pq.peek();
9+
}
10+
}

0 commit comments

Comments
 (0)