171. 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
链接: 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 }
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步