[Python] O(1) with explanation
Accoding to the defination, the smallest lexicographically string must have the patten as \n\n\t\ts = \'a\' * p + t * q + \'z\' * r\n\t\twhere p, r >= 0, \'a\' 
Accoding to the defination, the smallest lexicographically string must have the patten as \n\n\t\ts = \'a\' * p + t * q + \'z\' * r\n\t\twhere p, r >= 0, \'a\' < t < \'z\', q = 0 or 1\n\nThus, we have:\n```\n1. k = 1 * p + val_t * q + 26 * r\n2. p + q + r = n\n```\n\nThen k = (n - q - r) + val_t * q + 26 * r = n + q * (val_t - 1)  + r * 25.\nLet tt = val_t - 1, then 0 < tt < 25, hence:\n\n\t\tk - n = r * 25 + q * tt, where 0 <= q * tt < 25\n\t\t\t\t\nso we have:\n\n\t\tr, q * tt = divmod(k - n, 25)\n\t\tq = 1 if q * tt > 0 else 0\n\t\ttt = q * tt\n\t\tp = n - r - q\n\nThen the answer will be \n\n\t\ts = \'a\' * p + t * q + \'z\' * r\n\n```\nclass Solution(object):\n    def getSmallestString(self, n, k):\n        """\n        :type n: int\n        :type k: int\n        :rtype: str\n        """\n        r, qt = divmod(k - n, 25)\n        q = 1 if qt else 0\n        p = n - q - r\n        return \'a\' * p + chr(ord(\'a\') + qt) * q + \'z\' * r\n```\n\n
[]