C approach using alternative hi/lo
We want to observe we can create k differences by alternating the lowest and highest numbers not yet used. The number range is 1.. n as per the problem statemen
We want to observe we can create k differences by alternating the lowest and highest numbers not yet used. The number range is 1.. n as per the problem statement.\n* The smallest difference found will be 1\n* One way to alternate hi/lo inserts and count   is to use the k value : both for odd/even test (use hi or lo) and   decrement it (count  differences generated).\n* Once all k differences are present, the algo re-use diff 1, that  is just keep adding 1 to lowest used number\n\n```\nint* constructArray(const int n, int k, int* returnSize){\n\n    int *res = (int *) malloc (n * sizeof(int));\n      \n        int lo = 1;\n        int hi = n;\n    int idx = 0;\n     //create k differences\n    while (k) {\n        if ((k & 1) == 1)\n            *(res + idx) = lo++;\n        else\n            *(res + idx) = hi--;\n        --k; ++idx;\n    }\n    //re-use 1-size difference (if numbers left to fill)\n    for (;idx < n; ++idx) {\n        *(res + idx) = lo++;\n    }\n    *returnSize = idx;\n    \n    return res;\n}\n```
['C']