PROBLEMS|MOD 07|MEDIUM

Kth Largest Element in an Array

Lists & Tuples

Given a non-empty list of numbers `arr`, return the maximum value.

// EXAMPLES

Example 1:
Input: Input: [3, 5, 2, 8, 1]
Output: 8
Explanation: Result for example 1 of Kth Largest Element in an Array.
Example 2:
Input: Input: [-10, -3, -20]
Output: -3
Explanation: Result for example 2 of Kth Largest Element in an Array.

// CONSTRAINTS

  • 1 <= len(input) <= 10^5
  • Time Complexity target: O(N) or O(N log N)
  • Space Complexity target: O(1) or O(N)
  • Evaluated against 300 test cases.
solution.py