In case you need see the solution [C++]


#1

int Solution::titleToNumber(string A) {

int ans = 0;
int s = A.size();

for( int i=1; i<=s; i++ ){
    
    ans += pow(26,s-i) * ( (int)A[i-1] - 64 );
}

return ans;

}


#2

But for large string(like for length 100), how can the answer fit in 2 byte or 4 byte int variable?? range of answer will be [1,26^26] which is beyond the max range of int or even long long .