A simple C solution beats 100.00 %  12ms
// .1 2 3 4 5 6 7  distinct integers 1\n// 7.1 2 3 4 5 6   distinct integers 6 1\n// 7 1.6 5 4 3 2   distinct integers 6 5 1\n// 7 1 6.2 3 4 5   distinct intege
// .1 2 3 4 5 6 7  distinct integers 1\n// 7.1 2 3 4 5 6   distinct integers 6 1\n// 7 1.6 5 4 3 2   distinct integers 6 5 1\n// 7 1 6.2 3 4 5   distinct integers 6 5 4 1\n//...\n// 7 1 6 2 5 3 4.   distinct integers 6 5 4 3 2 1\n\nint* constructArray(int n, int k, int* returnSize) {\n    *returnSize = n;\n    int *resultArr = (int*)calloc(n,sizeof(int));\n  \n    for(int i = 0,right = n ; i< k/2    ; i++, right-- )\n        resultArr[2*i] = right;\n    \n    for(int i = 0,left = 1 ; i< (k-1)/2 ; i++, left++ )\n        resultArr[1 + 2*i] = left;\n        \n     for(int i= 0 ; i< n-k+1 ; i++){\n         if(k % 2 == 0)//\u5076\u6570\u6B63\u5E8F\n            resultArr[i+k-1] = i + (k+1)/2 ;\n         else//\u5947\u6570\u9006\u5E8F\n            resultArr[i+k-1] = n-i -k/2 ;\n     }\n    \n    return resultArr;\n    \n}
[]