1.Description
Find the **k**th largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.
For example,
Given [3,2,1,5,6,4]
and k = 2, return 5.
Note:
You may assume k is always valid, 1 ≤ k ≤ array’s length.
解读
找到无序数组中第k大的那个数字,
2.Solution
2.1每次找到最大的数,从list中删除,循环k-1次,返回最大的值
class Solution(object):
def findKthLargest(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: int
"""
while k>1:
nums.remove(max(nums))
k-=1
#print(max(nums))
return max(nums)
效率27.57%