My java 1ms solution 93% faster
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    // 1 2 3 4 5\n    // 1 5 4 3 2\n    // 1 5 2 3 4\n    public int[] constructArray(int n, int k) {\n        int[] res = new int[n];\n        res[0] = 1;\n        int l = 2, h = n;\n        int flip = 0;\n        for(int i = 1; i < n; i++){\n            if(k > 1){\n                flip ^= 1;\n                k--;\n            }\n            if(flip == 1){\n                res[i] = h--;\n            }else{\n                res[i] = l++;\n            }\n        }\n        return res;\n    }\n}\n```
['Java']