LeetCode力扣 168. Excel表列名称 Excel Sheet Column Title 题解代码 JavaScript

瑾谋

关注

阅读 70

2023-03-07


问题 ​​https://leetcode-cn.com/problems/excel-sheet-column-title/​​

练习使用JavaScript解答

/**
* @param {number} n
* @return {string}
*/
var convertToTitle = function(n) {
var str = [], j;
while(n>0) {
--n;
j = n % 26;
str.push(String.fromCharCode(j+'A'.charCodeAt()));
n = Math.floor(n/26);
}
return str.reverse().join("");
};

 

精彩评论(0)

0 0 举报