Neat, and easy understand in java


  • 0
    C
    public class Solution {
        public int titleToNumber(String s) {
            if(s == null || s.length() == 0){
                return 0;
            }
            int res = 0;
            for(char c : s.toCharArray()){
                res = res * 26 + c - 'A' + 1;
            }
            return res;
            
        }
    }

Log in to reply
 

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