-
Notifications
You must be signed in to change notification settings - Fork 0
171_ExcelSheetColumnNumber
a920604a edited this page Apr 14, 2023
·
1 revision
class Solution {
public:
int titleToNumber(string columnTitle) {
int ret = 0, n = columnTitle.size();
for(int i=0;i<n;i++){
ret = 26*ret ;
ret+=columnTitle[i]-'A'+1;
}
return ret;
}
};
- time complexity
O(n)
- space complexity
O(1)
footer