python - excel sheet


  • 0
    S
    class Solution(object):
        def convertToTitle(self, n):
            """
            :type n: int
            :rtype: str
            """
            # special handling for multiples of 26 in the loop
            ans = []
            while(n > 26):
                r = n%26
                ans.append(r if r else 26)
                n = n/26 - (1 if not r else 0);
                
            ans.append(n)
            
            return ''.join([chr(ord('A') + c-1) for c in ans][::-1])
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.