Share my 0ms java solution


  • 1
    C
    public String convertToTitle(int n) {
        char[] convertWords = new char[8];
        int index = convertWords.length - 1;
        for(; n > 0; index--){
            int remainder = (n - 1) % 26;
            n = (n - 1) / 26;
            convertWords[index] = (char) ('A' + remainder);
        }
        return new String(convertWords, index + 1, convertWords.length - index - 1);
    }

Log in to reply
 

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