Java Solution with simple loop


  • 0
    L
    public int titleToNumber(String s) {
            int num=0;
            for(char c : s.toCharArray()) {
                num = num*26 + c+1 - 'A';
            }
            
            return num;
        }
    

Log in to reply
 

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