```
public class Solution {
public void rotate(int[] nums, int k) {
if(nums.length==1) return;
rotate(nums,nums.length-k,nums.length-1);
rotate(nums,0,nums.length-k-1);
rotate(nums,0,nums.length-1);
}
public void swap(int[] nums,int a,int b){
int temp = nums[a];
nums[a] = nums[b];
nums[b] = temp;
}
public void rotate(int[] nums,int start,int end){
for(int i = start;i<=(start+end)/2;i++){
swap(nums,i,(start+end)-i);
}
}
```

}

```
Line 11: java.lang.ArrayIndexOutOfBoundsException: -1
Last executed input: [1,2], 2
```