publicinttitleToNumber(String s) {if (s ==null||s.isEmpty()) {return0; }HashMap<Character,Integer> charToInt =newHashMap<>();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;}
publicinttitleToNumber(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;}