C++ Simple Solution
\nclass Solution {\npublic:\n    vector<int> constructArray(int n, int k) {\n        int i=1,j=n;\n        vector<int>ans;\n        int f=-1;\n        while(k){
```\nclass Solution {\npublic:\n    vector<int> constructArray(int n, int k) {\n        int i=1,j=n;\n        vector<int>ans;\n        int f=-1;\n        while(k){\n            f=-1;\n            if(k){\n                ans.push_back(i);\n                k--;\n                i++;\n                f=0;\n            }\n            if(k){\n                ans.push_back(j);\n                k--;\n                j--;\n                f=1;\n            }\n        }\n        if(f==0){\n            while(i<=j){\n                ans.push_back(i);\n                i++;\n            }\n        }else if(f==1){\n            while(i<=j){\n                ans.push_back(j);\n                j--;\n            }\n        }\n        return ans;\n    }\n};\n```
[]