Oms Java Solution using StringBuffer


  • 1
    Y
    public String convertToTitle(int n) {
        StringBuffer result = new StringBuffer();
        while(n>0){
            int temp = n%26==0?26:n%26;
            result.append((char)(64+temp));
            n=(n-temp)/26;
        }
        result.reverse();
        return result.toString();
    }

Log in to reply
 

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