171. Excel Sheet Column Number
Last updated
Last updated
/**
* Time complexity : O(N) where N is the number of characters in the input string.
* Space complexity : O(1)
*/
class Solution {
public int titleToNumber(String s) {
int result = 0;
for(int i = 0; i < s.length(); i++) {
result *= 26;
result += (s.charAt(i)-'A')+1;
}
return result;
}
}