c++ O(n) easy solution
\nfetch 1~k + 1 to satisfy the requirement(like 1 , k + 1, 2, k, 3, k - 1,.....)\n'''\nclass Solution {\npublic:\n    vector constructArray(int n, int k) {\n   
\nfetch 1~k + 1 to satisfy the requirement(like 1 , k + 1, 2, k, 3, k - 1,.....)\n'''\nclass Solution {\npublic:\n    vector<int> constructArray(int n, int k) {\n        int x = 1, y = k + 1;\n        std::vector<int> v;\n        while(x < y)\n        {\n            v.push_back(x);   \n            v.push_back(y);\n            x++;\n            y--;\n        }\n        if(x == y)\n            v.push_back(x);\n        for(int i = k + 2; i <= n; i++)\n            v.push_back(i);\n        return v;\n    }\n};
[]