2 LINE java recursive solution


  • 0
    A

    public class Solution {

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

    }


Log in to reply
 

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