Hyoseo Lee
01 Index 02 Current page Writing 03 Work 04 Notes 05 Games 06 Author
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

  • Time: - Space complexity: