accepted java solution


  • 0
    K

    public String convertToTitle(int n) {

        StringBuilder stbr = new StringBuilder("");  
        while(n!=0){ 
            int x = n%26;
            if(x==0) x = 26;
            char c = (char)(65 + x -1);
            stbr.insert(0,c);
            n = (n - x)/26;
        }
      
        return stbr.toString();  
    }

Log in to reply
 

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