1663. Smallest String With A Given Numeric Value
On This Page
class Solution:
def getSmallestString(self, n: int, k: int) -> str:
res = ['a'] * n
i, d = n - 1, k - n
while d > 25:
res[i] = 'z'
d -= 25
i -= 1
res[i] = chr(ord(res[i]) + d)
return ''.join(res)