Java solution 6 lines


  • 0
    B
    public static String convertToTitle(int n) {
        StringBuilder sb = new StringBuilder();
    
        while (n-- != 0){
            sb.append((char)(n%26+'A'));
            n = n/26;
        }
    
        return  sb.reverse().toString();
        
    }

Log in to reply
 

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