public void recoverRotatedSortedArray(ArrayList<Integer> nums) {
        // write your code
        // Collections.sort(nums);
        if (nums == null || nums.size() <= 1)
            return;
        int i = 1;
        // rotate in three ways
        // first find the rotate point
        for (; i < nums.size(); ++i) {
            if (nums.get(i) < nums.get(i - 1))
                break;
        }
        if (i >= nums.size())
            return;
        // rotate
        rotate(nums, 0, i - 1);
        rotate(nums, i, nums.size() - 1);
        rotate(nums, 0, nums.size() - 1);
    }