my solution with java


  • 0
    S

    class Solution {
    public int titleToNumber(String s) {
    if(s==null) return 0;
    //A 65 相当于26进制运算
    int sum=0;
    int len = s.length();
    for(int i=len-1;i>=0;i--){
    int now =(s.charAt(i)-64)*(int)Math.pow(26,len-i-1);
    sum+=now;
    }
    return sum;
    }
    }


Log in to reply
 

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