Excel Sheet Column Number
题目:
Related to question Excel Sheet Column Title
Given a column title as appear in an Excel sheet, return its corresponding column number.
For example:
A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28
解析:
实际上就是26进制,自己写的:
1 class Solution { 2 public: 3 int titleToNumber(string s) { 4 int n = 0; 5 for(int i = s.size()-1,j = 0; i >= 0; i--,j++) 6 n += (int(s[i])-64) * pow(26,j); 7 return n; 8 } 9 };