题目:

         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学习心得

相关文章:

  • 2021-06-25
  • 2021-08-04
  • 2021-11-16
  • 2021-06-04
  • 2021-10-03
  • 2021-04-06
  • 2021-12-11
  • 2021-06-26
猜你喜欢
  • 2021-05-01
  • 2021-10-26
  • 2022-01-01
  • 2021-09-07
  • 2021-09-26
  • 2021-06-05
  • 2021-11-12
相关资源
相似解决方案