LeetCode Excel Sheet Column Number 171
171. Excel Sheet Column Number 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 自己的思路 很像是“二十六进制”转十进制 public int titleToNumber(String s) { int col = 0; char[] chars = s.toCharArray(); int i = 0; while (i < chars.length) { int charInt = chars[chars.length - 1 - i] - 64; col += Math.pow(26, i) * charInt; i++; } return col; } 在算法问题中常常用到: ...