leetcode icon indicating copy to clipboard operation
leetcode copied to clipboard

Duplicate Solution: 215-Kth-Largest-Element-in-an-Array.py

Open abe-101 opened this issue 4 years ago • 1 comments

It seams the python code in this solution is a mix of two seperate approaches:

  1. 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
  2. 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.

abe-101 avatar Jul 25 '22 17:07 abe-101

I made a PR to refactor the solution into two separate classes. #668

KC10201 avatar Jul 28 '22 02:07 KC10201