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

        final int n = nums.length;

        if (n <= 1) {
            return;
        }

        while (n < k) {
            k = k % n;
        }

        if (n == k) {
            return;
        }

        reverse(nums, 0, n - 1);
        reverse(nums, 0, k - 1);
        reverse(nums, k, n - 1);

    }