Easy Solution by reversing the string


#1

int Solution::titleToNumber(string a) {
int p=0,sum=0;
for(int i=a.size()-1;i>=0;i–)
{
sum+=pow(26,p++)*(a[i]-‘A’+1);
}
return sum;
}