Accepted java solution


  • 0
    V

    public class Solution {

    public int titleToNumber(String s) {
        int result = 0;
        int num = 0;
        int count = 0;
        if(s.length() == 0 || s == null){
            return 0;
        }
        
        for(int i = s.length() - 1; i >= 0; i--){
            num =s.charAt(i) - 'A' + 1;
            count = (int)Math.pow(26, s.length() - 1 -i);
            result = result + num * count; 
        }
        
        return result;
    }
    

    }

    fxxk


Log in to reply
 

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