- 进制转换
/**
*
* @description 思路跟10进制转2进制一样,类比一下即可
* @param {number} n
* @return {*} {string}
*/
function convertToTitle(n: number): string {
let result: string = '';
while (n > 0) {
const offset: number = (n - 1) % 26;
result = getUpperCase(offset) + result;
n = Math.floor((n - 1) / 26);
}
return result;
};
function getUpperCase(num: number): string {
return String.fromCharCode(num + 65);
}