• This project
    • Loading...
  • Sign in

Shenlin / leetcode-test

Itomix
Go to a project
Toggle navigation Toggle navigation pinning
  • Projects
  • Groups
  • Snippets
  • Help
  • Project
  • Activity
  • Repository
  • Pipelines
  • Graphs
  • Issues 0
  • Merge Requests 0
  • Wiki
  • Snippets
  • Network
  • Create a new issue
  • Builds
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Network
  • Compare
  • Branches
  • Tags
Switch branch/tag
  • leetcode-test
  • 168-convertToTitle.js
  • lintry's avatar
    已完成的答案 · f21637e1
    f21637e1
    lintry authored 2019-06-18 14:23:17 +0800
168-convertToTitle.js 347 Bytes
Raw Blame History Permalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/**
 * @param {number} n
 * @return {string}
 */
var convertToTitle = function(n) {
    let title = [];
    while (n--) {
        let c = n%26+1;
        console.info(n, c, String.fromCharCode(64+c));
        n = ~~(n / 26); 

        title.unshift(String.fromCharCode(64+c));
    }
    return title.join('');
};

console.info(convertToTitle(701))