docs(docs): add Approach diagrams and Explanation sections to LeetCode problem documentation

This commit is contained in:
Prad Nukala committed 2026-09-21 15:53:21 -04:00
1 parent b8c779903f
commit 23eb71d387
19 files changed
+439

No files matched your search

@@ -21,6 +21,20 @@ sidebar:
- `1 <= k <= nums.length <= 10^5`
- `-10^4 <= nums[i] <= 10^4`
## Approach
```mermaid
flowchart TD
S(["findKthLargest(nums, k)"]) --> F{"more i in range(len(nums))?"}
F -- yes --> N["nums[i] = -nums[i] — negate so the min-heap acts as a max-heap"]
N --> F
F -- no --> H["heapq.heapify(nums)"]
H --> W{"more _ in range(k - 1)?"}
W -- yes --> P["heapq.heappop(nums) — discard the k-1 largest"]
P --> W
W -- no --> E(["return -heapq.heappop(nums)"])
```
## Solution
```py
@@ -39,3 +53,7 @@ class Solution:
return -heapq.heappop(nums)
```
## Explanation
<YouTube id="XEmy13g1Qxc" title="Kth Largest Element in an Array - Quick Select - Leetcode 215 - Python" />