Lint Code #5. 第k大元素
[问题地址]:https://www.lintcode.com/problem/kth-largest-element/description
解法一:
class Solution:
"""
@param n: An integer
@param nums: An array
@return: the Kth largest element
"""
def kthLargestElement(self, n, nums):
# write your code here
assert nums and 0<n<=len(nums)
nums.sort(reverse=True)
return nums[n-1]
说明:熟练并灵活使用Python自带函数很重要。