```
class Solution {
public:
int titleToNumber(string s) {
int digit = s.length();
int num = 0;
for(int i = 0; i < digit-1; i++)
{
num += s[i] - 'A' + 1;
num *= 26;
}
return (num + s[digit-1] - 'A' + 1);
}
};
```

I also tried using pow() function, it makes computation slower. The solution above faster than using pow() function, but need to be careful to avoid overflow.