Java Solution: Self Explanatory


  • 1
    C
    public int titleToNumber(String s) {
        int len = s.length();
    	int sum = 0;
    	for (int i = 0; i < len; i++) {
    		sum=sum*26 + (s.charAt(i) - 'A'+1);
    	}
    	return sum;
    }

Log in to reply
 

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