[C++] Simple pattern matching algorithm
\nclass Solution {\npublic:\n    vector<int> constructArray(int n, int k) {\n        vector<int> ans(n);\n        int odd=k+1;\n        int even=1;\n        for
```\nclass Solution {\npublic:\n    vector<int> constructArray(int n, int k) {\n        vector<int> ans(n);\n        int odd=k+1;\n        int even=1;\n        for(int i=0;i<n;i++){\n            ans[i]=i+1;\n        }\n        for(int i=0;i<=k;i++){\n            if(i%2==0){\n                ans[i]=even;\n                even++;\n            }\n            else{\n                ans[i]=odd;\n                odd--;\n            }\n        }\n        return ans;\n    }\n};\n```
['C', 'C++']