public void rotate(final int[] nums, final int k) {

        if (nums.length <= 1) {
            return;
        }

        final int[] tmp = new int[nums.length];
        for (int i = 0; i < nums.length; i++) {
            if (i + k < nums.length) {
                tmp[i + k] = nums[i];
            } else {
                tmp[(i + k) % nums.length] = nums[i];
            }
        }

        for (int i = 0; i < nums.length; i++) {
            nums[i] = tmp[i];
        }

    }