LeetCode: 189. Rotate Array
题目描述
Given an array, rotate the array to the right by k
steps, where k is non-negative.
Example 1:
Example 2:
Note:
- Try to come up as many solutions as you can, there are at least
3
different ways to solve this problem. - Could you do it in-place with
O(1)
extra space?
解题思路
递归求解,一次移动一位。
AC 代码