题目:
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
链接: http://leetcode.com/problems/excel-sheet-column-number/
2/20/2017, Java
1 public class Solution { 2 public int titleToNumber(String s) { 3 int value = 0; 4 char c; 5 for (int i = 0; i < s.length(); i++) { 6 c = s.charAt(i); 7 value = value * 26 + (c - 'A' + 1); 8 } 9 return value; 10 } 11 }