Day 30: LeetCode 215 [Kth Largest Element in an Array]
Problem Description: Given an integer array nums and an integer k, return the kth largest element in the array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Can you solve it without sorting?
Example 1: Input: nums = [3,2,1,5,6,4], k = 2 Output: 5 Example 2:
Link to LeetCode Problem: https://leetcode.com/problems/kth-largest-element-in-an-array/description/
learned about PriorityQueue
which is a Java Collections Framework.
A priority queue is a data structure that allows you to add elements and retrieve the smallest (or largest) element efficiently. In this case, we use a min-heap priority queue, which means that the smallest element is always at the top of the queue.