Excel Sheet Column Number

Easy

Excel column titles are a base-26 system: A = 1, B = 2, … Z = 26, AA = 27.

Given a column title s, return its column number.

Example 1

titleToNumber()
Input
s = "A"
Output
1

Example 2

titleToNumber()
Input
s = "AB"
Output
28

Why

1 * 26 + 2
Constraints
1 <= s.length <= 7
`s` consists of uppercase English letters only.

Topics

MathStrings

Implement titleToNumber in the editor and return the answer — printing it is never graded.