/
githubmirror
/
LeetCodeAnimation
Обзор
Документация
Войти
/
githubmirror
/
LeetCodeAnimation
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
problems/0215-Kth-Largest-Element-in-an-Array/Code/1.java
18 строк
524 B
吴至波
docs: organize assets and add animation previews
10 июн 2026, 10:57
10 июн 2026, 10:57
3711846
Код
Авторство
О чём код?
class Solution { public int findKthLargest(int[] nums, int k) { // // ����һ��С���ѣ����ȶ���ģ�⣩ PriorityQueue<Integer> heap = new PriorityQueue<Integer>(); // �ڶ���ά����ǰ���k��Ԫ�� for (int i = 0; i < nums.length; i++){ if(heap.size() < k){ heap.add(nums[i]); }else if (heap.element() < nums[i]){ heap.poll(); heap.add(nums[i]); } } return heap.poll(); } }