class Solution {
public int titleToNumber(String s) {
int n = 0;
for (int i = 0; i < s.length(); i++) {
n= n * 26 + (int)s.charAt(i) - 64;
}
return n;
}
}
```
class Solution:
def titleToNumber(self, s: str) -> int:
num = 0
for i in s:
num = num * 26 + (ord(i) - 64)
return num