Greedy Simple Approach
\nclass Solution {\n    public int[] constructArray(int n, int k) {\n        int [] result = new int[n];\n        result[0] = 1;\n        int sign = 1;\n       
```\nclass Solution {\n    public int[] constructArray(int n, int k) {\n        int [] result = new int[n];\n        result[0] = 1;\n        int sign = 1;\n        for(int i = 1 ; i < n; i++, k--){\n            if(k > 0){\n                result[i] = result[i-1] + k * sign;\n                sign *= -1;\n            }\n            else{\n                result[i] = i+1;\n            }\n        }\n        return result;\n    }\n}\n```
['Greedy', 'Java']