Kth Largest Element in an Array

LeetCode

LeetCode: https://leetcode.com/problems/kth-largest-element-in-an-array/

Given an integer array nums and an integer k, return the kth largest element in the array.

1def findKthLargest(nums: List[int], k: int) -> int:
2 nums.sort()
3 return nums[-k]
3
0
2
1
3
2
1
3
2
4
4
5
5
6
5
7
6
8
k=4
Step 1 / 3
Step 1:
We will sort nums, then read the element at index n-k.
Focus: select @ [0]
k=4