Skip to content

Latest commit

 

History

History
17 lines (15 loc) · 410 Bytes

168.md

File metadata and controls

17 lines (15 loc) · 410 Bytes

168. Excel Sheet Column Title

Solution 1 (time O(1), space O(1))

class Solution(object):
    def convertToTitle(self, columnNumber):
        """
        :type columnNumber: int
        :rtype: str
        """
        ans = ""
        while columnNumber:
            ans += chr(ord("A") + (columnNumber - 1) % 26)
            columnNumber = (columnNumber - 1) / 26
        return ans[::-1]