题解 | #向左移动牛群#
向左移动牛群
https://www.nowcoder.com/practice/e70fc604c3684ce294e6af5e97feff04
import java.util.*;
public class Solution {
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param nums int整型一维数组
* @param k int整型
* @return int整型一维数组
*/
public int[] rotateCows (int[] nums, int k) {
// write code here
while(k-- > 0){
int tmp = nums[nums.length - 1];
for(int i = nums.length - 2;i >= 0;i--){
nums[i + 1] = nums[i];
}
nums[0] = tmp;
}
return nums;
}
}
