该题目是实际上是要将10进制转换为26进制。代码如下:
1 class Solution {
2 public String convertToTitle(int n) {
3 String res = new String();
4
5 while( n != 0 ){
6 int r = (n-1)%26;
7 n = (n-1) / 26;
8 res = ((char)('A' + r)) + res;
9 }
10
11 return res;
12 }
13 }
END