水题 LeetCode-171 Excel表列序号
题目链接:LeetCode-171 Excel
题目大意:把字符串转化为字典序的序号
解题思路:直接相加即可 需要用到Math.pow()函数
代码块:
class Solution {
public int titleToNumber(String s) {
int len = s.length();
int score = 0;
for(int i=0;i<len;i++){
score += Math.pow(26,len-i-1) * (s.charAt(i)-'A'+1);
}
return score;
}
}