Python O(n)
Complexity
Time complexity: O(n)

Space complexity: O(n)
Code
# Complexity
- Time complexity: O(n)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(n)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def constructArray(self, n: int, k: int) -> List[int]:
        """
            we need to alternate between +- k, whatever the current value is.

            and we need to populate the array n-k times. 
        """
        answer = []
        for i in range(1, n-k+1):
            answer.append(i)
        sign = 1
        while k:
            newval = answer[-1] + sign*k
            sign = -sign
            answer.append(newval)
            k -=1
        
        return answer

```
['Python3']