Find the k'th Largest or Smallest Element

Table of Contents:

Intro 0:00 - 0:45
The Problem Introduction 0:45 - 2:20
Approach #1: Just Sort The Array & Count K Back 2:20 - 3:50
Approach #2: Heap Based Approach 3:50 - 5:02
Min Heap Approach Walkthrough 5:02 - 7:41
Seeing How We Can Improve Further 7:41 - 9:51
We Realize What We Need To Do 9:51 - 10:43
Where Will The k'th Largest Element End Up? 10:43 - 13:19
Approach #3: Walking Through A Partition Step 13:19 - 16:58
Approach #3: The Deep Deep Deep Understanding 16:58 - 20:43
Analysis: Looking At The Recurrence 20:43 - 24:53
Analysis: Solving The Recurrence 24:53 - 27:14
Analysis: Our Final Result 27:14 - 28:11
Wrap Up (and space complexity) 28:11 - 29:54

Code: https://github.com/bephrem1/backtobackswe/blob/master/Sorting%2C%20Searching%2C%20%26%20Heaps/KthLargestElement/KthLargestElement.java
Leetcode Link: https://leetcode.com/problems/kth-largest-element-in-an-array/
Elements of Programming Interviews: 12.8

Discussion

0 comments