From a87769a8bff5fdd0548a48a3fb1343f584c37490 Mon Sep 17 00:00:00 2001 From: CyC2018 <1029579233@qq.com> Date: Sat, 12 May 2018 23:04:57 +0800 Subject: [PATCH] auto commit --- notes/剑指 offer 题解.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/notes/剑指 offer 题解.md b/notes/剑指 offer 题解.md index 4e0d83d8..edb0006c 100644 --- a/notes/剑指 offer 题解.md +++ b/notes/剑指 offer 题解.md @@ -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);