C++ Super Simple Easy and Short Explained Solution. 0 ms, faster than 100%
Explanation:\nWe pick the numbers alternating between the beginning index and end index until we have k differences, and when we finish we just add the rest of 
**Explanation:**\nWe pick the numbers alternating between the beginning index and end index until we have k differences, and when we finish we just add the rest of the numbers.\nSo we start off with i = 1 and j = n.\nWe add to res i, and increase it, and then j, and decrease it, then decrease k.\n**For example:**\nn = 7, k = 6\nres = 1, 7, 2, 6, 3, 5, 4\nThis is for the case that k is the maximum - n-1.\nIf k is less, and we finish it before adding all the numbers, we just add the rest in the end with difference 1.\n**For example:**\nn = 7, k = 3\nres = 1, 7, 2 - then k reaches 1, we go to \'else\' and add - 3, 4, 5, 6.\nso res = 1, 7, 2, 3, 4, 5, 6 - exactly k differences.\n\n```\nclass Solution {\npublic:\n    vector<int> constructArray(int n, int k) {\n        vector<int> res;\n        int i = 1, j = n;\n        \n        while (i <= j) {\n            if (k > 1)\n                k-- % 2 ? res.push_back(i++) : res.push_back(j--);\n            \n            else \n                res.push_back(i++);\n        }\n        return res;\n    }\n};\n```\n**Like it? please upvote!**
['C']