GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — SolvedAlgorithm/Sorting Algorithm/215.md at main · EsperErWang/SolvedAlgorithm

Expand file tree

/

215.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
16 lines (14 loc) · 382 Bytes
/

215.md

Copy path

File metadata and controls

16 lines (14 loc) · 382 Bytes
Raw
Copy raw file
Download raw file
Edit and raw actions
// simple PriorityQueue problem
public int findKthLargest(int[] nums, int k) {
    PriorityQueue<Integer> minPQ = new PriorityQueue<Integer>
        ((a, b) -> Integer.compare(a, b));

    for (int n : nums) {
        minPQ.add(n);
        if (minPQ.size() > k) {
            minPQ.poll();
        }            
    }
    return minPQ.poll();        
}
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.