C++ simple concise solution without any even/odd check
Understand with an example ... n=8, k=5, minm_val(left)=1, maxm_val(right)=8\ntake the result array and fill it upto the (n-k) value, i.e., till (n-k-1)th index
Understand with an example ... n=8, k=5, minm_val(left)=1, maxm_val(right)=8\ntake the result array and fill it upto the (n-k) value, i.e., till (n-k-1)th index with left++...\nhence, array after this operation becomes 1,2,3...\nthen run the loop for (n-k)th till the last index and fill up the array with alternate values of right-- and left++ .. array becomes ---->> 1,2,3,8,4,7,5,6 \nthats our answer ... with exactly k different differences \n\n```\nclass Solution {\npublic:\n    vector<int> constructArray(int n, int k) {\n        \n        vector<int>res(n,0);\n        \n        int left=1,right=n,i=0;\n        \n        while(i<n-k)res[i++]=left++;\n      \n        while(i<n){\n            \n            res[i++]=right--;\n            \n            if(i==n)break;\n            \n            res[i++]=left++;\n            \n        }\n        return res;\n    }\n};\n```
['Math', 'C']