Share my Java solution


  • 5
    Z

    here is my Java solution

     public class Solution {
        public int titleToNumber(String s) {
            int colNumber = 0;
            
    		for (int i = 0; i < s.length(); i++) {
    			colNumber = colNumber*26 + ((int)s.charAt(i)-64);
    	    }
            
            return colNumber;
        }
    }

Log in to reply
 

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