其他分享
首页 > 其他分享> > quickSort use two pointers to decrease Time into O(n * lgn ) or O(n)

quickSort use two pointers to decrease Time into O(n * lgn ) or O(n)

作者:互联网

Quicksort, 选取pivot, 然后有两个指针, left = 0, right = n - 1, left 不停右移找到nums[left] > pivot, right 不停左移找到nums[right] <= pivot直到left >= right, 停止,那么这时候再recursive nums[0: left] and nums[left:] 即可最后sort所有的数值

 

应用:

[LeetCode] 75. Sort Colors_Medium tag: Two pointers

 

标签:use,right,lgn,nums,pointers,不停,pivot,left
来源: https://www.cnblogs.com/Johnsonxiong/p/14942987.html