https://leetcode.com/problems/excel-sheet-column-number/
class Solution { public: int titleToNumber(string s) { int ans = 0; for(int i = 0;i < s.length();i++) { ans *= 26; ans += s[i] - ‘A‘ + 1; } return ans; } };
时间: 2024-10-11 07:40:07
https://leetcode.com/problems/excel-sheet-column-number/
class Solution { public: int titleToNumber(string s) { int ans = 0; for(int i = 0;i < s.length();i++) { ans *= 26; ans += s[i] - ‘A‘ + 1; } return ans; } };