C++ | easy solution | 100% faster
\nclass Solution {\npublic:\n    vector<int> constructArray(int n, int k) {\n        vector<int> res(n);\n        for(int i = 0;i<=k;i++)\n        {\n          
```\nclass Solution {\npublic:\n    vector<int> constructArray(int n, int k) {\n        vector<int> res(n);\n        for(int i = 0;i<=k;i++)\n        {\n            if(i == 0)\n            {\n                res[i] = 1;\n                continue;\n            }\n            if(i==1)\n            {\n                res[i] = k+1;\n                continue;\n            }\n            if(i%2==0)\n                res[i] = res[i-2]+1;\n            else\n                res[i] = res[i-2] -1; \n        }\n        for(int i = k+1;i<n;i++)\n        {\n            res[i] = i+1;\n        }\n        return res;\n    }\n};\n```
['C']