189. Rotate Array

来源:互联网 发布:客户满意率的数据来源 编辑:程序博客网 时间:2024/06/08 15:44
 public static void rotate(int[] nums, int k) {        if(nums == null || nums.length <=1) {            return;        }        int circle = k % nums.length;        for(int i = 0; i < circle; i++) {            int tmp = nums[nums.length-1];            int j = nums.length-1;            while(j >= 1) {                nums[j] = nums[j-1];                j--;            }            nums[j] = tmp;        }    }
0 0
原创粉丝点击