Excel Sheet Column Title

Problem Id: 168 Difficulty: Easy


Intuition

Solution


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