C++ concise code
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

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

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

# Code
```cpp []
vector<int> constructArray(int n, int k) {
    vector<int> ans(n);
    ans[0] = 1;
    for (int i=k, j=1; i>=1; i--, j++) 
        ans[j] = (j % 2) ? ans[j-1] + i : ans[j-1] - i;
    iota(ans.begin() + k + 1, ans.end(), k + 2); 
    return ans;
}
```
['C++']