← Back to challenges

Excel Sheet Column Title

PythonHardnumbersstrings

Instructions

Given a positive integer, return its corresponding column title displayed in Excel sheets.

For example:

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

Examples

convert_to_title(1) ➞ "A"

convert_to_title(18) ➞ "R"

convert_to_title(28) ➞ "AB"

convert_to_title(52) ➞ "AZ"

convert_to_title(701) ➞ "ZY"

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.