leetcode
leetcode copied to clipboard
Duplicate Solution: 215-Kth-Largest-Element-in-an-Array.py
It seams the python code in this solution is a mix of two seperate approaches:
- Sort and return kth element. N log N runtime https://github.com/neetcode-gh/leetcode/blob/baff88f8772b1a7a75614f3c937407f5388015d9/python/215-Kth-Largest-Element-in-an-Array.py#L3-L4
- QuickSelect. Linear runtime on average https://github.com/neetcode-gh/leetcode/blob/baff88f8772b1a7a75614f3c937407f5388015d9/python/215-Kth-Largest-Element-in-an-Array.py#L6-L26
I would advise to separate into two separate functions or at a minimum use comments to clarify.
I made a PR to refactor the solution into two separate classes. #668