LeetCode Excel Sheet Column Title

Given a positive integer, return its corresponding column title as appear in an Excel sheet.

For example:

    1 -> A
    2 -> B
    3 -> C
    ...
    26 -> Z
    27 -> AA
    28 -> AB 

 1 public class Solution {
 2     public String convertToTitle(int n) {
 3         String ret="";
 4         
 5         while (n>0) {
 6             n--;
 7             char letter=(char) (n%26+'A');
 8             ret=letter+ret;
 9             n=n/26;
10         }
11         
12         return ret;
13         
14     }
15 }
原文地址:https://www.cnblogs.com/birdhack/p/4178969.html