Given an array, rotate the array to the right by k steps, where k is non-negative....示例 1:
输入: [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:
输入: [-1,-100,3,99] 和 k = 2
输出: [3,99,-1,-100]
解释:
向右旋转 1 步: [99,-1...:4,3,2,1,7,6,5
反转整个数组: 5,6,7,1,2,3,4
输出: 5,6,7,1,2,3,4
Java(反转数组):
class Solution {
public void rotate...Python3(利用切片):
class Solution:
def rotate(self, nums: List[int], k: int) -> None:
"""