python 3 || O(n)
```\nclass Solution:\n    def getSmallestString(self, n: int, k: int) -> str:\n        res = \'\'\n        for i in range(n):\n            q, r = divmod(k, 26)\
```\nclass Solution:\n    def getSmallestString(self, n: int, k: int) -> str:\n        res = \'\'\n        for i in range(n):\n            q, r = divmod(k, 26)\n            if r == 0:\n                q -= 1\n                r = 26\n\n            if n - q - i >= 2:\n                res += \'a\'\n                k -= 1\n            else:\n                res += chr(r + 96) + \'z\' * (n - i - 1)\n                break\n        \n        return res
['Greedy', 'Python', 'Python3']