c++ | easy | fast
\n\n# Code\n\nclass Solution {\npublic:\n    vector<int> constructArray(int n, int k) {\n        vector<int> ans(n);\n        for (int i = 0, a = 1, z = k + 1; 
\n\n# Code\n```\nclass Solution {\npublic:\n    vector<int> constructArray(int n, int k) {\n        vector<int> ans(n);\n        for (int i = 0, a = 1, z = k + 1; i <= k; i++)\n            ans[i] = i % 2 ? z-- : a++;\n        for (int i = k+1; i < n; i++)\n            ans[i] = i + 1;\n        return ans;\n    }\n};\n```
['C++']