标签:number for class nbsp strong bsp excel let 四十
给定一个Excel表格中的列名称,返回其相应的列序号。
例如,
A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ...
示例 1:
输入: "A" 输出: 1
示例 2:
输入: "AB" 输出: 28
示例 3:
输入: "ZY" 输出: 701
class Solution: def titleToNumber(self, s): """ :type s: str :rtype: int """ result = 0 for i in range(len(s)): result *= 26 result += ord(s[i]) - ord(‘A‘) + 1 return result
标签:number for class nbsp strong bsp excel let 四十
原文地址:https://www.cnblogs.com/flashBoxer/p/9508932.html