33.93 %
class Solution {
public int titleToNumber(String s) {
if (s == null || s.length() == 0) return 0;
int result = 0;
for (int i = 0; i < s.length(); i++) {
char curr = s.charAt(i);
// 'A' -> 1
result = result * 26 + curr - 'A' + 1;
}
return result;
}
}
No comments:
Post a Comment