Java: 4 lines


  • 0
    R
      public int titleToNumber(String s) {
        int sum = 0;
        for (char c : s.toCharArray()) {
            sum = sum * 26 + (c - 'A' + 1);    
        }
        
        return sum;
    }

Log in to reply
 

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