Leetcode 168 Solution
This article provides solution to leetcode question 168 (excel-sheet-column-title)
Access this page by simply typing in "lcs 168" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/excel-sheet-column-title
Solution
class Solution:
def convertToTitle(self, columnNumber: int) -> str:
ans = []
v = columnNumber
while v > 0:
if v <= 26:
ans.append(chr(ord('A') + v - 1))
break
else:
ans.append(chr(ord('A') + (v - 1) % 26))
v = (v - 1) // 26
return "".join(reversed(ans))