6 Line C++ & Python Solution O(1) Time (Better than 100%)
We first take x as k - n as we need to have space for all the n characters  in the string.\nSince we need to get the lexicographically smallest string we need t
We first take **x** as **k - n** as we need to have space for all the **n** characters  in the string.\nSince we need to get the lexicographically smallest string we need to get the value of **x** below 25 by inserting all **z**\'s at the end.\nOnce we get the **x** below 25 we insert the character corresponding to it and then insert all **a**\'s in the beginning.\n**C++ Solution:**\n```\nclass Solution {\npublic:\n    string getSmallestString(int n, int k) {\n        int x = k - n;\n        string ans = string(x / 25, \'z\');\n        x %= 25;\n        if (x) \n            ans = (char)(\'a\' + x) + ans;\n        return string(n - ans.length(), \'a\') + ans;\n    }\n};\n```\n\n**Python Solution:**\n```\nclass Solution:\n    def getSmallestString(self, n: int, k: int) -> str:\n        x = k - n\n        ans = \'z\'*(x // 25)\n        x %= 25\n        if x:\n            ans = chr(ord(\'a\') + x) + ans\n        return \'a\'*(n - len(ans)) + ans\n```
['C', 'Python', 'Python3']