[Python] Simple solution, explained
Just create sentence 1,2, . . . , n\u2212k, n, n\u2212k+ 1, n\u22121, . . ., where we start to take biggest and smallest elements from place n\u2212k.  Let us c
Just create sentence `1,2, . . . , n\u2212k, n, n\u2212k+ 1, n\u22121, . . .`, where we start to take biggest and smallest elements from place `n\u2212k`.  Let us consider case `n = 14` and `k = 6`, then what  `[1,2,3,4,5,6,7,8,14,9,13,10,12,11]`: then first differences are equal to `1`, then we have differencese `6, -5, 4, -3, 2, -1`, so in the end we will have absolute differences `1, 2, 3, 4, 5, 6`.\n\n#### Complexity\nTime complexity is `O(n)`, space as well to form output array\n\n#### Code\n```\nclass Solution:\n    def constructArray(self, n, k):\n        dr, diff = 1, k\n        result = list(range(1, n-k+1))\n        for i in range(k):\n            result.append(result[-1] + dr*diff)\n            dr *= -1\n            diff -= 1      \n        return result\n```
['Math']