My Java Use StringBuilder 0ms


  • 2
    public class Solution {
        public String convertToTitle(int n) {
        	StringBuilder sb = new StringBuilder();
            while(n!=0){	
            	sb.insert(0,(char)('A' + --n % 26));
            	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.