0ms java solution


  • 0
    J
    public class Solution {
    	public void rotate(int[] nums, int k) {
    		k = k % nums.length;
    		int[] tmp = new int[nums.length];
    		System.arraycopy(nums, nums.length - k, tmp, 0, k);
    		System.arraycopy(nums, 0, tmp, k, nums.length - k);
    		System.arraycopy(tmp, 0, nums, 0, nums.length);
    	}
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.