Given a string columnTitle that represents the column title as appears in an Excel sheet, return its corresponding column number. For example: A → 1, B → 2, ..., Z → 26, AA → 27, AB → 28, ..., ZY → 701.

Input: columnTitle = "A"
Output: 1
Input: columnTitle = "AB"
Output: 28
Explanation: A=1, B=2. AB = 1*26 + 2 = 28.
Input: columnTitle = "ZY"
Output: 701

This is essentially a base-26 to decimal conversion. Process characters left to right, accumulating the result by multiplying by 26 at each step and adding the value of the current character (A=1, B=2, ..., Z=26).

class Solution { public int titleToNumber(String columnTitle) { int result = 0; for (char c : columnTitle.toCharArray()) { result = result * 26 + (c - 'A' + 1); } return result; } }
Complexity Analysis:

Time complexity: O(n) where n is the length of the column title string.
Space complexity: O(1) — only a result variable is used.