class Solution {
public int[] decrypt(int[] code, int k) {
int[] res=new int[code.length];
if(k>0){
for (int i = 0; i < res.length; i++) {
for (int j = i+1; j < i+1+k; j++) {
if(j<res.length){
res[i]+=code[j];
}else{
res[i]+=code[j-code.length];
}
}
}
}else if(k<0){
for (int i = 0; i < res.length; i++) {
for (int j = i-1; j>i-1+k; j--) {
if(j>=0){
res[i]+=code[j];
}else{
res[i]+=code[code.length+j];
}
}
}
}else{
res=new int[code.length];
}
return res;
}
}