Skip to content

Instantly share code, notes, and snippets.

@kninami
Created October 25, 2016 01:45
Show Gist options
  • Select an option

  • Save kninami/28b639b158874272570eeca59c549f7d to your computer and use it in GitHub Desktop.

Select an option

Save kninami/28b639b158874272570eeca59c549f7d to your computer and use it in GitHub Desktop.
class Solution {
public int[] solution(int[] A, int K) {
int[] result = new int[A.length];
int length = 0;
if(K!=0 && A.length!=0){ length = K%A.length; }
for(int i=0;i<A.length;i++){
if(i+length<A.length){
result[i+length] = A[i];
}else{
result[i+length-A.length] = A[i];
}
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment