Tricky JAVA 0ms solution


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

  • 0
    P

    o ms,i guessed the way........


Log in to reply
 

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