Solution:
# T:O(lgn) S:O(1)
class Solution:
# @param {integer} n
# @return {string}
def convertToTitle(self, n):
result, dvd = "", n
while dvd:
result += chr((dvd - 1) % 26 + ord('A'))
dvd = (dvd - 1) / 26
return result[::-1]
Run Time: 36 ms
No comments:
Post a Comment