Clean java solution


  • 0
    L

    public class Solution {

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

    }


Log in to reply
 

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