題目:
給定一個正整數,返回它在 Excel 表中相對應的列名稱。
例如,
1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB ...
示例 1:
輸入: 1 輸出: "A"
示例 2:
輸入: 28 輸出: "AB"
示例 3:
輸入: 701 輸出: "ZY"
python代碼:
class Solution:
def convertToTitle(self, n):
res = ''
while n:
res = chr((n-1)%26 + 65) + res
n = (n-1)//26
return res