标签:leetcode
https://oj.leetcode.com/problems/rotate-array/
public class Solution { public void rotate(int[] nums, int k) { int len = nums.length; int head = len - (k % len); int[] copy = new int[len]; for (int i = 0 ; i < len ; i ++) { copy[i] = nums[(i + head) % len]; } for (int i = 0 ; i < len ; i ++) { nums[i] = copy[i]; } } }
标签:leetcode
原文地址:http://7371901.blog.51cto.com/7361901/1615188