[LeetCode]Excel Sheet Column Number
public class Solution { public int titleToNumber(String s) { int result = 0; int tmp = 1; for (int i = s.length() - 1; i >= 0; i--) { result += (s.charAt(i) - 'A' + 1) * tmp; tmp *= 26; } return result; } }
public class Solution { public int titleToNumber(String s) { int result = 0; int tmp = 1; for (int i = s.length() - 1; i >= 0; i--) { result += (s.charAt(i) - 'A' + 1) * tmp; tmp *= 26; } return result; } }