0ms 4 lines iterative java solution


  • -1
    O
    public String convertToTitle(int n) {
        StringBuilder sb = new StringBuilder();
        for ( ; n > 0; n /= 26)
        	sb.insert(0, (char)('A' + --n % 26));
        return sb.toString();
    }

Log in to reply
 

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