auto commit

This commit is contained in:
CyC2018 2018-05-12 23:04:57 +08:00
parent 5ce7099730
commit a87769a8bf

View File

@ -1805,13 +1805,10 @@ public int findKthSmallest(int[] nums, int k) {
private int partition(int[] nums, int l, int h) {
// 切分元素
int parti = nums[l];
// [l + 1, i) (j, h]
int i = l + 1, j = h;
int i = l, j = h + 1;
while (true) {
while (i != h && nums[i] < parti)
i++;
while (j != l && nums[j] > parti)
j--;
while (i != h && nums[++i] < parti) ;
while (j != l && nums[--j] > parti) ;
if (i >= j)
break;
swap(nums, i, j);