题解 | #Excel 表列序号#
https://www.nowcoder.com/practice/700738eaa67342ba8f92c13cbbb7b29d
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param n int整型 * @return string字符串 */ function ExcelTitle( n ) { const s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; const map = new Map(); for (let i = 0; i < s.length; i++) { map.set(i+1, s[i]); } let res = ''; while(n) { let d = n % 26; if (d=== 0) { res = 'Z' + res; n = n - 26; } else { res = (map.get(d) || '') + res; } n = Math.trunc(n/26); } return res; // write code here } module.exports = { ExcelTitle : ExcelTitle };