192. Excel Sheet Column Number
Easy · Math
Given a string representing a column title as it appears in an Excel sheet, return the corresponding column number.
In Excel, columns are labeled as follows: A=1, B=2, ..., Z=26, AA=27, AB=28, ..., AZ=52, BA=53, and so on. This is essentially a base-26 number system where A-Z represent digits 1-26 (not 0-25).
Examples
Example 1 Input: "A" Output: 1 Explanation: A is the first column, so the answer is 1.
Example 2 Input: "AB" Output: 28 Explanation: A=1, B=2, so AB = 1*26 + 2 = 28.
Example 3 Input: "ZZ" Output: 702 Explanation: Z=26, so ZZ = 26*26 + 26 = 676 + 26 = 702.
Constraints
- Standard input/output constraints apply