Back to Browse

Heap - 3: Find Kth Largest Value in given array | Using Min Heap | Using Max Heap

23.2K views
Apr 6, 2020
11:54

Source Code:https://thecodingsimplified.com/find-kth-largest-value-in-given-array/ Solution - 1: using Min heap - Crate min heap of k size - Now keep adding other element - If current value is less than peek value, then we need not do anything - If current value is greater than peek value, we poll top value & insert current value - At last after iteration of all value, the peek of minHeap will be 3rd Largest Solution - 2: using Max heap - Create max heap & insert all value into it - Now poll k - 1 values from it - Now the peek value at the moment will be 3rd largest value Do Watch video for more info CHECK OUT CODING SIMPLIFIED https://www.youtube.com/codingsimplified ★☆★ VIEW THE BLOG POST: ★☆★ http://thecodingsimplified.com I started my YouTube channel, Coding Simplified, during Dec of 2015. Since then, I've published over 400+ videos. ★☆★ SUBSCRIBE TO ME ON YOUTUBE: ★☆★ https://www.youtube.com/codingsimplified?sub_confirmation=1 ★☆★ Send us mail at: ★☆★ Email: [email protected]

Download

0 formats

No download links available.

Heap - 3: Find Kth Largest Value in given array | Using Min Heap | Using Max Heap | NatokHD