Skip to content
Decoder

Excel Sheet Column Number

Easy

Problem

Spreadsheet columns are labelled A, B, ..., Z, AA, AB, ..., AZ, BA, .... Given a column title, return its column number (A is 1, Z is 26, AA is 27).

Example 1

Input
columnTitle = "A"
Output
1

Example 2

Input
columnTitle = "AB"
Output
28

Example 3

Input
columnTitle = "ZY"
Output
701

Constraints

  • 1 <= columnTitle.length <= 7
  • columnTitle contains only uppercase English letters.
  • columnTitle is in the range ["A", "FXSHRXW"].

Read it once before you touch anything

Want some pressure? Start the timer. In an interview you get about two minutes to understand the problem.

  1. 1Read the goalWhat goes in, what comes out
  2. 2Scan the examplesCheck one by hand
  3. 3Note the constraintsThey set your Big O
Say what it asks in one sentence
Say it out loud first, then compare with ours.