题目: 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 提示: 此题考查的是对N进制数转10进制数的转换. 代码: 我自己的…
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 { pu…
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 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 -…
---------------------------------- 乘权相加即可. AC代码:(从右往左) public class Solution { public int titleToNumber(String s) { int res=0; for(int i=s.length()-1;i>=0;i--) res+=(s.charAt(i)-'A'+1)*((int)(Math.pow(26,s.length()-i-1))); return res; } } 精简版AC代码:(从左…
题目描述: Excel Sheet Column Title Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB Excel Sheet Column Number Related to question Exc…