My Java code, with minimum number of multiplications(without Math.pow)


  • 2
    S
    public class Solution {
        public int titleToNumber(String s) {
            int l = s.length();
            int count = 0;
            for(int i = 0; i<l;i++ ){
                count = count*26  +s.charAt(i)-'A' + 1;
            }
            return count;
        }
    }

Log in to reply
 

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