Short Java Solution with Explaination
From observation, for the first K+1 items in the result array should be like this: start from 1 as ans[0],  then ans[1] = ans[0]+k, ans[2] = ans[1]-(k-1), ans[3
From observation, for the first K+1 items in the result array should be like this: start from 1 as ans[0],  then ans[1] = ans[0]+k, ans[2] = ans[1]-(k-1), ans[3] = ans[2]+(k-1-1),...ans[i] = ans[i-1]+0...\nThe sign flips each time until 0, and afterward, all the difference between two adjacent items could be 1, that is ans[i] = i+1. Here comes the code:\n```\nclass Solution {\n    public int[] constructArray(int n, int k) {\n        int[] ans = new int[n];\n        ans[0] = 1;\n        int v = k;\n        int sign = 1;\n        for(int i = 1; i < n; i++) {\n            if(k == 1 || v == 0){\n                ans[i] = i+1;\n                continue;\n            }          \n            ans[i] = ans[i-1] + v*sign;\n            v--;\n            sign = -sign;\n        }\n        return ans;\n    }\n}\n```\n
[]