Preview:
class Solution {
public:
    int findKthLargest(vector<int>& nums, int k) {
        priority_queue<int,vector<int>,greater<int>>minH;
        for(int i=0;i<nums.size();i++)
        {
            minH.push(nums[i]);
            if(minH.size()>k)
            {
                minH.pop();
            }
        }
    return minH.top();
    }
};
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter