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解题思路:
class Solution { public: int titleToNumber(string s) { int len=s.length(); if(len==0){ return 0; } int result = 0; for(int i=0; i<len; i++){ result *= 26; result += s[i] - 'A' + 1; } return result; } };
[LeetCode] Excel Sheet Column Number
原文地址:http://blog.csdn.net/kangrydotnet/article/details/44999463