JAVA Solution


  • 0
    J
    class Solution {
             //this problem is similar to the problem that is 26 decimal to 10 decimal.
           public int titleToNumber(String s) {
                 int sum=0;
    	    for(int i=0;i<s.length();i++)
            {
                int k = s.charAt(i)-64;
                sum+=Math.pow(26,s.length()-1-i)*k;
            }
    		return sum;
    	 }
    }
    

Log in to reply
 

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