Leetcode - kth Largest Element In An Array (Kotlin)

Опубликовано: 18 Октябрь 2024
на канале: Coffee Bytez
142
4

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

Join the Coffee Bytez Patreon for exclusive content:
  / coffeebytez  

Substack:
https://coffeebytez.substack.com/

Medium:
  / coffeebytez  

Discord:
  / discord  

#leetcode #kotlin #array #priorityqueue