[C++] 5 lines "Fill slot" solution | O(n)
For example:\nn = 9, k = 5\n1. 1 2 3 4 5 6 7 8 9\n2. 1 2 2 4 3 6 7 8 9\n3. 1 5 2 4 3 6 7 8 9\n\n\nclass Solution {\npublic:\n    vector<int> constructArray(int 
For example:\nn = 9, k = 5\n1. 1 2 3 4 5 ***6 7 8 9***\n2. ***1*** 2 ***2*** 4 ***3*** 6 7 8 9\n3. 1 ***5*** 2 ***4*** 3 6 7 8 9\n\n```\nclass Solution {\npublic:\n    vector<int> constructArray(int n, int k) {\n        vector<int> res(n);\n        for(int i = 1; i <= n; ++i) res[i-1] = i;\n        for(int i = 1; i <= k/2+1; ++i) res[(i-1)*2] = i;\n        for(int i = k+1; i > k/2+1; --i) res[(k+1-i)*2+1] = i;\n        return res;\n    }\n};\n```
[]