这题相对来说比较简单。~
class Solution: def titleToNumber(self, columnTitle: str) -> int: res=0 length = len(columnTitle) for i in range(length): res+=pow(26,length-i-1)*(ord(columnTitle[i])-64) return res
int titleToNumber(char * columnTitle){ int res=0; int length = strlen(columnTitle); for(int i=0;i<length;i++) res+=pow(26,length-i-1)*(columnTitle[i]-64); return res; }
每日LeetCode - 171. Excel表列序号(C语言+Python 3)
原文:https://www.cnblogs.com/vicky2021/p/14920257.html