easyMathArrays & Hashing

Excel Sheet Column Number

easyTime: O(n)Space: O(1)

Recognize the pattern

Excel column letters to numberbase-26 with A=1left-to-right accumulation

Brute force idea

Not applicable — direct computation.

Better approach

result = result × 26 + (char - 'A' + 1). Process left to right. O(n).

Key invariant

It's base-26 but 1-indexed: A=1, B=2, ..., Z=26. Each position multiplied by 26^distance from right.

Watch out for

Using A=0 — Excel columns are 1-indexed.

Arrays & Hashing Pattern