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) { private int partition(int[] nums, int l, int h) {
// 切分元素 // 切分元素
int parti = nums[l]; int parti = nums[l];
// [l + 1, i) (j, h] int i = l, j = h + 1;
int i = l + 1, j = h;
while (true) { while (true) {
while (i != h && nums[i] < parti) while (i != h && nums[++i] < parti) ;
i++; while (j != l && nums[--j] > parti) ;
while (j != l && nums[j] > parti)
j--;
if (i >= j) if (i >= j)
break; break;
swap(nums, i, j); swap(nums, i, j);