Share my java solution


  • 0
    R
       public int titleToNumber(String s) {
        		int result = 0;
                for(int i=0; i<s.length()-1; i++){
                	char temp = s.charAt(i);
                	result += (temp-'A'+1)*26*Math.pow(26, s.length()-i-2);
                }
                return result+(s.charAt(s.length()-1)-'A'+1);
            }

Log in to reply
 

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