/168. Excel Sheet Column Title

168. Excel Sheet Column Title

Easy
Probability46% acceptance

Given a positive integer n, return its corresponding string representation in a base-26 system where digits are mapped to uppercase English letters (A to Z). The mapping is such that 1 maps to A, 2 to B, ..., 26 to Z, 27 to AA, 28 to AB, and so on.

Example 1

Input: n = 52

Output: AZ

Explanation: 52 maps to AZ in Excel column title system.

Example 2

Input: n = 703

Output: AAA

Explanation: 703 maps to AAA in Excel column title system.

Example 3

Input: n = 18278

Output: ZZZ

Explanation: 18278 maps to ZZZ in Excel column title system.

Constraints

  • 1 <= n <= 231 - 1
Python (current runtime)

Case 1

Input: n = 100

Expected: 'CV'

Case 2

Input: n = 260

Expected: 'JD'

Case 3

Input: n = 1378

Expected: 'BZZ'

Case 4

Input: n = 475254

Expected: 'ZZZZ'

Case 5

Input: n = 702

Expected: 'ZZ'