题目
链接
题解
class Solution {
public int titleToNumber(String columnTitle) {
// 结果
int res = 0;
// 进制累乘项
int n = 1;
for (int i = columnTitle.length() - 1, j = 0; i >= 0 ; i--, j++) {
int num = convert(columnTitle.charAt(i));
res += n * num;
n *= 26;
}
return res;
}
private int convert(char ch) {
return ((int)ch) - 64;
}
}