```
class Solution {
public int[] constructArray(int n, int k) {
int[] result = new int[n];
int max = k+1;
for(int i = 0; i < k+1 ; i++){
if(i % 2 == 0){
result[i] = i/2 + 1;
}
else{
result[i] = max - i/2;
}
}
for(int i = k+1; i < n; i++){
result[i] = i+1;
}
return result;
}
}
```