Excel Sheet Column Title(math)

Given a positive integer, return its corresponding column title as appear in an Excel sheet.

For example:

  1 -> A
    2 -> B
    3 -> C
    ...
    26 -> Z
    27 -> AA
    28 -> AB 
    ...

Example 1:

Input:
 1

Output:
 "A"

Example 2:

Input:
 28

Output:
 "AB"

Example 3:

分析

就是模拟十进制数,个位数%,十位数/,注意这里是n-1,不是N

python ord 和 chr

分治

每次递归结果+最低位的char

Last updated

Was this helpful?