public class Solution {
public int titleToNumber(String s) {
if (s == null || s.length() == 0) {
return 0;
}
int result = 0;
int i = s.length() - 1;
int n = 0;
while (i >= 0) {
char c = s.charAt(i);
result += (int) Math.pow(26, n) * (c - 'A' + 1);
n++;
i--;
}
return result;
}
}
Excel Sheet Column Number
最新推荐文章于 2021-03-12 09:08:33 发布