Backward-filling with an early exit [bad code!]
There is one optimization in the code below that is helpful for large n: As soon as k == n, we know that the rest of the sought string is \'a\' (s. && k > n in 
There is one optimization in the code below that is helpful for large `n`: As soon as `k == n`, we know that the rest of the sought string is `\'a\'` (s. `&& k > n` in the `while` condition).\n\nWhile this code works, there are a few bad coding practices here which should be avoided:\n1. Re-use of variables: the arguments `n` and `k` are used and modified directly. It would be better to have local variables with speaking names instead.\n2. `--` is used inline twice. Yes, it makes the code more concise, but also less readable.\n3. No comments whatsoever. If you implement an algorithm, its non-trivial parts should be commented.\n\nAnd now the code:\n```csharp\npublic string GetSmallestString(int n, int k)\n{      \n    var res = new char[n--];\n    Array.Fill(res, \'a\');\n    \n    while (n >= 0 && k > n)\n    {\n        int c = Math.Min(26, k - n);\n        k -= c;\n        res[n--] = (char)(c + \'a\' - 1);\n    }\n    \n    return new String(res);\n}\n```
['C#']