clueless coding // TODO: be smarter

LeetCode Excel Sheet Column Title: Java Solution



TL;DR Code Solution


public String convertToTitle(int n) {

      StringBuilder result = new StringBuilder();

    while(n>0){
        n--;
        result.insert(0, (char)('A' + n % 26));
        n /= 26;
    }

    return result.toString();

}