168.Excel Sheet Column Title

 

 

class Solution:
    def convertToTitle(self, n: int) -> str:
        ans = ""
        while n:
            a = (n-1) % 26
            n = (n-1) // 26
            ans = chr(ord('A') + a) + ans
        return ans

 

posted @ 2020-05-09 14:47  星海寻梦233  阅读(83)  评论(0编辑  收藏  举报