1. 程式人生 > >LeetCode 168: Excel Sheet Column Title

LeetCode 168: Excel Sheet Column Title

leetcode builder build -- clas uil sheet style ring

class Solution {
    public String convertToTitle(int n) {
        if (n <= 0) {
            return "";
        }
        StringBuilder result = new StringBuilder();
        while (n-- > 0) {
            result.insert(0, (char)(‘A‘ + n % 26));
            n /= 26;
        }
        return result.toString();
    }
}

LeetCode 168: Excel Sheet Column Title