observation mechanical steps 60% faster
1.start with 1always.\n2.till k is not sufficed, alternate values of high and low are to be inserted viz. high starts from n and low starts from 2 (as 1 is defa
1.start with 1always.\n2.till k is not sufficed, alternate values of high and low are to be inserted viz. high starts from n and low starts from 2 (as 1 is defaulted as first element)\n3.once done, we have to fill array till it reaches n, for that, whatever is the last element, if its from high, we keep on padding array with decrementing values of high\n4.else if low, we keep on padding array with incrementing values of low.\n```\nclass Solution {\npublic:\n    vector<int> constructArray(int n, int k) {\n     vector<int> arr(n , 0);\n     int high = n , low = 2,index = 0;\n     bool isHigh = false;\n     arr[index++] = 1;   \n     while(k>1){\n         arr[index++] = high--;\n         isHigh = true;\n         k--;\n         if(k > 1){\n             arr[index++]= low++;\n             k--;\n             isHigh=false;\n         }\n     }\n     while(index < n){\n         if(isHigh){\n             arr[index++] = high--;\n         }\n         else{\n             arr[index++] = low++;\n         }\n     }\n        return arr;\n    }\n};\n```
[]