Unexpected TLE
I'm not certain this code produces the correct answer, however I was surprised to get TLE. I originally was using push_back on the vector, but even with a size 
I'm not certain this code produces the correct answer, however I was surprised to get TLE. I originally was using `push_back` on the vector, but even with a size initializer to avoid multiple heap allocations it still takes too long on the input `(9999,9998)`. On my machine, this code runs in about 8 *micro*seconds, or about 2.5 clocks per `n`, so I don't really know what's going on here.\n```\nvector<int> constructArray(int n, int k) {\n    vector<int> ret(n);\n    int d = n - 1;\n    int c = 1;\n    bool low = true;\n    int idx = 0;\n    ret[idx++] = c;\n    for (int i = 0; i < k - 1; i++)\n    {\n        if (low) c += d--;\n        else c -= d--;\n        ret[idx++] = c;\n        low = !low;\n    }\n    for (int i = k; i < n; i++)\n    {\n        if (low) c++;\n        else c--;\n        ret[idx++] = c;\n    }\n    return ret;\n}\n```\n\n**Edit:**\nI even tried alexander's "[Clean Code 4-liner](https://discuss.leetcode.com/topic/101113/c-java-clean-code-4-liner)" solution and it takes over 8 times as long, mostly spent in vector-realloc.\n\n**Edit 2:**\nOk so I just resubmitted this code as-is and it was accepted... Wouldn't have impacted my ranking in the contest much, but still I'd like to know what might have caused TLE in the first place.  In case it matters, my submissions were all within about 10 minutes of the end of the contest.
[]