Excel Sheet Column Number

EasyStringMath

Description

Given a string columnTitle that represents the column title as appears in an Excel sheet, return its corresponding column number. A -> 1, B -> 2, ... Z -> 26, AA -> 27, AB -> 28, etc.

Examples

Input:columnTitle = "A"
Output:1
Explanation:

A maps to 1 in the Excel column system. Single letters A-Z represent columns 1-26.

Input:columnTitle = "AB"
Output:28
Explanation:

Like base-26 numbers: A(1) in the 26s place contributes 1*26=26, B(2) in the 1s place adds 2. Total: 26+2=28.

Input:columnTitle = "ZY"
Output:701
Explanation:

Z(26) in the 26s place contributes 26*26=676. Y(25) in the 1s place adds 25. Total: 676+25=701.

Constraints

  • 1 ≤ columnTitle.length ≤ 7
  • columnTitle consists only of uppercase English letters.

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!