Different solution in Java for reference


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

Log in to reply
 

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