Java short 2 ms solution


  • 0
    M
    public class Solution {
    public int titleToNumber(String s) {
        int sum = 0;
        for(int k = 0; k < s.length(); k++) {
            sum *= 26;
            sum += (s.charAt(k) - 'A' + 1);
        }
        return sum;
    }
    }

  • 0
    G

    This information is really beautiful! I really like it.


Log in to reply
 

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