https://leetcode.com/problems/excel-sheet-column-number/description/
int titleToNumber(string s) {
int res = 0;
int n = 1;
for(int i=s.size()-1;i>=0;i--) {
res += n*(s[i]-'A' + 1);
n *= 26;
}
return res;
}
No comments:
Post a Comment