给定一个整数数组 nums,将数组中的元素向右轮转 k 个位置,其中 k 是非负数。
示例 1:
 输入: nums = [1,2,3,4,5,6,7], k = 3
 输出: [5,6,7,1,2,3,4]
 解释:
 向右轮转 1 步: [7,1,2,3,4,5,6]
 向右轮转 2 步: [6,7,1,2,3,4,5]
 向右轮转 3 步: [5,6,7,1,2,3,4]
示例 2:
 输入:nums = [-1,-100,3,99], k = 2
 输出:[3,99,-1,-100]
 解释:
 向右轮转 1 步: [99,-1,-100,3]
 向右轮转 2 步: [3,99,-1,-100]
解法一:利用栈
    const rotate = function (nums, k) {
        for (let i = 0; i < k; i++) {
            const popEl = nums.pop();
            nums.unshift(popEl)
        }
    };

解法二: 数组翻转
    const rotate2 = function (nums, k) {
        const reverse = (list, startIndex, endIndex) => {
            while (startIndex < endIndex) {
                const temp = list[startIndex];
                list[startIndex] = list[endIndex];
                list[endIndex] = temp;
                --endIndex;
                ++startIndex;
            }
        }
        k %= nums.length;
        // 翻转原来数组元素
        reverse(nums,0,nums.length-1);
        // 翻转索引0-k的元素
        reverse(nums,0,k-1);
        // 翻转索引k-数组最后索引的元素
        reverse(nums,k,nums.length-1);
    };






![解决使用WebTestClient访问接口报[185c31bb] 500 Server Error for HTTP GET “/**“](https://img-blog.csdnimg.cn/3dac1dcd794f4a03aafb03d6ef634b6a.png#pic_center)













