Leetcode - kth Largest Element In An Array
You can sort the array (nums) and return nums[ nums.size -k ] or use a PriorityQueue (as a min-heap) and only keep it at a size of k so the kth element will be at the front of the PriorityQueue after traversing the array
#leetcode #kotlin #array #priorityqueue
You can sort the array (nums) and return nums[ nums.size -k ] or use a PriorityQueue (as a min-heap) and only keep it at a size of k so the kth element will be at the front of the PriorityQueue after traversing the array
#leetcode #kotlin #array #priorityqueue
- Категория
- Язык программирования Kotlin
Комментариев нет.