public class Solution {
public int titleToNumber(String s) {
int title = 0, time = 1;
int len = s.length();
for (int i = len - 1; i >= 0; i--) {
title += ((s.charAt(i) - 'A' + 1) * time);
time *= 26;
}
return title;
}
}
LeetCode 171. Excel Sheet Column Number
最新推荐文章于 2024-02-17 11:47:40 发布