Skip to content

Commit e4acc50

Browse files
authored
Create Solution2.java
1 parent 6b8b9fe commit e4acc50

File tree

1 file changed

+12
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)