[C++] [Java] Clean Code 4-liner
if you have n number, the maximum k can be n - 1;\nif n is 9, max k is 8.\nThis can be done by picking numbers interleavingly from head and tail, \n\n// start f
if you have `n` number, the maximum `k` can be `n - 1`;\nif `n` is 9, max `k` is 8.\nThis can be done by picking numbers interleavingly from head and tail, \n```\n// start from i = 1, j = n;\n// i++, j--, i++, j--, i++, j--\n\ni: 1   2   3   4   5\nj:   9   8   7   6\nout: 1 9 2 8 3 7 4 6 5\ndif:  8 7 6 5 4 3 2 1\n```\nAbove is a case where `k` is exactly `n - 1`\nWhen k is less than that, simply lay out the rest `(i, j)` in incremental\n order(all diff is 1). Say if k is 5:\n```\n     i++ j-- i++ j--  i++ i++ i++ ...\nout: 1   9   2   8    3   4   5   6   7\ndif:   8   7   6   5    1   1   1   1 \n```\n**C++**\n```\nclass Solution {\npublic:\n    vector<int> constructArray(int n, int k) {\n        vector<int> res;\n        for (int i = 1, j = n; i <= j; ) {\n            if (k > 1) {\n                res.push_back(k-- % 2 ? i++ : j--);\n            }\n            else {\n                res.push_back(i++);\n            }\n        }\n\n        return res;\n    }\n};\n```\n\n**C++ Compact**\n```\nclass Solution {\npublic:\n    vector<int> constructArray(int n, int k) {\n        vector<int> res;\n        for (int i = 1, j = n; i <= j; )\n            res.push_back(k > 1 ? (k-- % 2 ? i++ : j--) : i++;\n        return res;\n    }\n};\n```\n**Java**\n```\nclass Solution {\n    public int[] constructArray(int n, int k) {\n        int[] res = new int[n];\n        for (int i = 0, l = 1, r = n; l <= r; i++)\n            res[i] = k > 1 ? (k-- % 2 != 0 ? l++ : r--) : l++;\n        return res;\n    }\n}\n```
[]