Excel Sheet Column Number

PHOTO EMBED

Thu Jun 23 2022 18:58:10 GMT+0000 (UTC)

Saved by @Ranjan_kumar #c++

class Solution {
public:
    int titleToNumber(string columnTitle) {
        int sum=0;
        
        int n=columnTitle.size();
        for(int i=0;i<n-1;i++)
        {
            sum=sum+pow(26,(n-i-1))*(columnTitle[i]-'A'+1);
        }
        sum=sum+(columnTitle[n-1]-'A'+1);
        return sum;
    }
};
content_copyCOPY

https://leetcode.com/problems/excel-sheet-column-number/