illuminati
1 min
Updated: Oct 4, 2020
Problem: Excel Column Title
Problem Description:
Given a positive integer A, return its corresponding column title as appear in an Excel sheet.
Problem Constraints
1 <= A <= 1000000000
Input Format
First and only argument is integer A.
Output Format
Return a string, the answer to the problem.
Example Input
Input 1:
A = 1
Input 2:
A = 28
Example Output
Output 1:
"A"
Output 2:
"AB"
Example Explanation
Explanation 1:
1 -> A
Explanation 2:
1 -> A
2 -> B
3 -> C
...
26 -> Z
27 -> AA
28 -> AB
This question is just about the base conversion. Think about what would you have done if instead of excel (base-26) you were given a binary.
Time Complexity: O(logN) -> base 26
Space Complexity: O(1)
Code in C++