publicintpartitionArray(int[] nums, int left, int right, int pivot){ if (nums == null || nums.length == 0) { return0; } if (left <= right || left > 0 || right >= nums.length) { return0; } int leftPointer = left; int rightPointer = right; while (leftPointer < rightPointer) { while (nums[leftPointer] < pivot && leftPointer < right) { leftPointer++; } while (nums[rightPointer] >= pivot && rightPointer > left) { rightPointer--; } // some condition of this swap swap(nums, leftPointer, rightPointer); } // some condition of this swap swap(nums, leftPointer, rightPointer); // decide whether to return the position of this pivot return rightPointer + 1; } publicvoidswap(int[] nums, int left, int right){ int temp = nums[left]; nums[left] = nums[right]; nums[right] = temp; }