Hyoseo Lee
Home About Projects Blog Thinking
leetcode

168. Excel Sheet Column Title

Topic Math
Area Algorithms
Summary
this question sucks. it's not even converting base question. and it is so stupid to solve this with C

Problem

View on LeetCode →

Difficulty: Easy
Tags: Math, String

Intuition

this question sucks. it’s not even converting base question. and it is so stupid to solve this with C

Solution

class Solution:
  def convertToTitle(self, n: int) -> str:
    return (self.convertToTitle((n - 1) // 26) + chr(ord('A') + (n - 1) % 26)
            if n
            else '')

Complexity