public int titleToNumber(String s) {
if (s == null || s.isEmpty()) {
return 0;
}
HashMap<Character, Integer> charToInt = new HashMap<>();
for (int i = 1, c = 'A'; i <=26; i++, c++) {
charToInt.put((char) c, i);
}
int res = 0;
for (int i = 0; i < s.length(); i++) {
res = res * 26 + charToInt.get(s.charAt(i));
}
return res;
}
public int titleToNumber(String s) {
if (s == null || s.isEmpty()) {
return -1;
}
int res = 0;
for (int i = 0; i < s.length(); i++) {
int cur = (int)(s.charAt(i) - 'A' + 1);
res = res * 26 + cur;
}
return res;
}