LeetCode编程练习 - Rotate Array学习心得

题目:

         Rotate an array ofn elements to the right byk steps.

        For example, withn = 7 andk = 3, the array[1,2,3,4,5,6,7] is rotated to[5,6,7,1,2,3,4].

    将n个元素的数组按k级旋转。例如,n = 7和k = 3,数组[1,2,3,4,5,6,7]被旋转到[5,6,7,1,2,3,4]。


思路:

    新建了一个数组,将反转后的值赋值给新的数组,最后再将新的数组赋值给原数组,但对于对数组的反转并不是很理解。%=是求两个操作数的模然后赋值给左边操作数。

LeetCode编程练习 - Rotate Array学习心得