快排提交失败8组用例成功了6个,为什码
class Solution:
def MySort(self , arr: List[int]) -> List[int]:
# write code here
self.quick_Sort(arr, 0, len(arr)-1)
return arr
def quick_Sort(self,arr,head,tail):
if head>=tail:
return arr
pivot=arr[head]
low=head
high=tail
while low!=high:
while low<high and arr[high]>=pivot:
high-=1
arr[low]=arr[high]
while low<high and arr[low]<=pivot:
low+=1
arr[high]=arr[low]
arr[low]=pivot
self.quick_Sort(arr, head, low-1)
self.quick_Sort(arr, low+1, tail)
def MySort(self , arr: List[int]) -> List[int]:
# write code here
self.quick_Sort(arr, 0, len(arr)-1)
return arr
def quick_Sort(self,arr,head,tail):
if head>=tail:
return arr
pivot=arr[head]
low=head
high=tail
while low!=high:
while low<high and arr[high]>=pivot:
high-=1
arr[low]=arr[high]
while low<high and arr[low]<=pivot:
low+=1
arr[high]=arr[low]
arr[low]=pivot
self.quick_Sort(arr, head, low-1)
self.quick_Sort(arr, low+1, tail)