标签:logs start end -- href tar ref class ota
public class Solution { public void reverse(int[] nums, int start, int end) { while (start < end) { int temp = nums[start]; nums[start] = nums[end]; nums[end] = temp; start++; end--; } } public void Rotate(int[] nums, int k) { k %= nums.Length; reverse(nums, 0, nums.Length - 1); reverse(nums, 0, k - 1); reverse(nums, k, nums.Length - 1); } }
https://leetcode.com/problems/rotate-array/#/description
标签:logs start end -- href tar ref class ota
原文地址:http://www.cnblogs.com/asenyang/p/6771226.html