```
public static int titleToNumber(String s){
char[] schar = s.toCharArray();
int length = s.length();
double sum = 0;
double y = 26;
for(int i =schar.length-1;i>=0;i--){
double x = length-1-i;
sum = sum + getVal(schar[i])*Math.pow(y,x);
}
return (int)sum;
}
public static int getVal(char c){
int val = c - 'A' +1;
return val;
}
```