public int partitionArray(int[] nums, int k) {
        //write your code here
        if (nums == null || nums.length == 0)
            return 0;
        int begin = 0, end = nums.length - 1, head = 0;
        while (begin <= end) {
            if (nums[begin] < k) {
                nums[head] = nums[begin];
                ++begin;
                ++head;
            } else {
                if (nums[end] >= k || nums[end] == nums[begin])
                    --end;
                else {
                    swap(nums, begin, end);
                }
            }
        }
        return head;
    }