๐ 171. Excel ่กจๅๅบๅท
2022ๅนด10ๆ10ๆฅ
- algorithm
๐ 171. Excel ่กจๅๅบๅท
้พๅบฆ: ๐
้ฎ้ขๆ่ฟฐ
่งฃๆณ
class Solution {
public int titleToNumber(String columnTitle) {
// ๆ่ทฏ๏ผ
// ไปๅๅพๅ้ๅ๏ผ้ๅฐๅญ็ฌฆ๏ผ่ฝฌๆขไธบๅผ ็ธๅ
int len = columnTitle.length();
int res = 0;
for(int i = 0; i < len; i ++) {
char c = columnTitle.charAt(i);
int val = c - 'A' + 1;
res = res * 26 + val;
}
return res;
}
}