https://leetcode.com/problems/excel-sheet-column-title/
Solution 1
/**
* @param {number} columnNumber
* @return {string}
*/
var convertToTitle = function (columnNumber) {
// String.fromCharCode(65) === "A"
// 한 자릿수일 경우
if (columnNumber - 1 < 26) {
return String.fromCharCode(65 + ((columnNumber - 1) % 26));
}
// 두 자릿수 이상일 경우
let result = '';
while (columnNumber > 0) {
const remainder = (columnNumber - 1) % 26;
const remainderCharCode = String.fromCharCode(65 + remainder);
result = remainderCharCode + result;
columnNumber = parseInt((columnNumber - 1) / 26);
}
return result;
};
다시 봐야함