Excel Sheet Column Number

Given a string columnTitle that represents the column title as it appears in an Excel sheet, return its corresponding column number.

Excel column titles work like a base-26 number system using letters:

  • A represents 1
  • B represents 2
  • ...
  • Z represents 26
  • AA represents 27
  • AB represents 28

Return the integer value represented by columnTitle.

Example 1
InputcolumnTitle = "A"
Output1
The column title A corresponds to column number 1.
Example 2
InputcolumnTitle = "AB"
Output28
The title AB represents 1 group of 26 plus 2, so its value is 28.

Constraints

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

Asked at 10 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate