TC-O(26*n),SC-O(26) ,C++


#1

int Solution::titleToNumber(string A) {

int n=A.size();
int sum=0;
 string s={'0','A','B','C','D','E','F','G','H','I','J',
 'K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
for(int i=0;i<n;i++)
{
    for(int j=1;j<=26;j++) 
      if(A[i]==s[j])
      {
          sum=sum*26+j;
      }
}
return sum;

}