public void sortColors(int[] nums) {
        if (nums == null) return;
        int i = 0, j = 0, k = nums.length - 1;
        while (j <= k) {
            if (nums[j] == 1) ++j;
            else if (nums[j] == 0) swap(nums, i++, j++);
            else swap(nums, j, k--);
        }
    }