Java Easy solution 3ms


  • 0
    F
    public class Solution {
        public int titleToNumber(String s){
            int res = 0;
            for(int i = s.length(); i > 0; i--){
                char c = s.charAt(s.length() - i);
                res += (c - 'A' + 1) * (int)Math.pow(26, i - 1);
            }
            return res;
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.