Using only system function in java

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

Log in to reply

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