classSolution:deffindKthLargest(self, nums: List[int], k:int)->int:# 递归实现快速排序defquickSort(nums):iflen(nums)<=1:return nums
left =[]
right =[]for i in nums[1:]:if i <= nums[0]:
left.append(i)else:
right.append(i)return quickSort(right)+[nums[0]]+ quickSort(left)return quickSort(nums)[k-1]
题目2
题解2
# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = NoneclassSolution:defreverseList(self, head: ListNode)-> ListNode:if head isNone:# 链表为空returnNoneif head.nextisNone:# 链表只有一个头节点return head
Pre =None
Next = head
while Next:
Next = Next.next
head.next= Pre
Pre = head
head = Next
return Pre