
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 public String convertToTitle(int n) {
if (n < 27) {
return (char) ('A' + (n - 1)) + "";
}
if (n % 26 == 0) {
return convertToTitle(n / 26 - 1) + 'Z';
}
return convertToTitle(n / 26) + convertToTitle(n % 26);
}原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。