My construction use 7 as example
Use 7 as an example, we can obtain some clue about the construction of the array.\n7, 1\n[1,2,3,4,5,6,7]  => [1,1,1,1,1,1]\n\n7,2\n[1,7,6,5,4,3,2] => [6,1,1,1,1
Use 7 as an example, we can obtain some clue about the construction of the array.\n7, 1\n[1,2,3,4,5,6,7]  => [1,1,1,1,1,1]\n\n7,2\n[1,7,6,5,4,3,2] => [6,1,1,1,1,1]\n\n7,3\n[1,7,2,3,4,5,6] => [6,5,1,1,1,1]\n\n7,4\n[1,7,2,6,5,4,3] => [6,5,4,1,1,1]\n\n7,5\n[1,7,2,6,3,4,5] => [6,5,4,3,1,1]\n\n7,6\n[1,7,2,6,3,5,4] => [6,5,4,3,2,1]\n\nBelow is my code implementation\n```\nclass Solution {\n    public int[] constructArray(int n, int k) {\n        int[] res = new int[n];\n        int i, j = 1, m = n, s;\n        for(i = 0; i < k; i ++) {\n            if(i % 2 == 0) {\n                res[i] = j;\n                j ++;\n            }\n            else {\n                res[i] = m;\n                m --;\n            }\n        }\n        s = i;\n        if(s % 2 == 1) {\n            for(s = i; s < n; s ++) {\n                res[s] = j;\n                j ++;\n            }\n        }\n        else {\n            for(s = i; s < n; s ++) {\n                res[s] = m;\n                m --;\n            }\n        }\n        return res;\n    }\n}\n\n```
[]