Given a positive integer, return its corresponding column title as appear in an Excel sheet.
For example:
1 -> A
2 -> B
3 -> C
...
26 -> Z
27 -> AA
28 -> AB
...
Input: 1 Output: "A"
Input: 28 Output: "AB"
Input: 701 Output: "ZY"
class Solution:
def convertToTitle(self, n: int) -> str:
ret = ""
while n > 0:
n -= 1
ret = chr(n % 26 + 65) + ret
n //= 26
return ret
# @param {Integer} n
# @return {String}
def convert_to_title(n)
ret = ""
while n > 0
n -= 1
ret = (n % 26 + 65).chr + ret
n /= 26
end
return ret
end