168. Excel Sheet Column Title
Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 43% Topics: Math, String
View full problem on LeetCode Reading material
Reference solution (spoiler · python)
# Time: O(logn)
# Space: O(1)
class Solution(object):
def convertToTitle(self, n):
"""
:type n: int
:rtype: str
"""
result = []
while n:
result += chr((n-1)%26 + ord('A'))
n = (n-1)//26
result.reverse()
return "".join(result)
Solution from kamyu104/LeetCode-Solutions · MIT