Optimal Algorithmic Approach
Randomized QuickSelect partition.
Core Invariants & Edge Cases
- Partition around a pivot (Lomuto or Hoare scheme)
- If pivot index == k, return; else recurse into the correct half
- Randomized pivot makes average O(n), worst O(n²)