首页 > 代码库 > Excel Sheet Column Number

Excel Sheet Column Number

https://leetcode.com/problems/excel-sheet-column-number/#/description

另一个atoi

/** * @param {string} s * @return {number} */var titleToNumber = function(s) {    var m = ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ‘.split(‘‘);    var d = {};    m.forEach(function(w, i){        d[w] = i + 1;    });    // console.log(d);    var len = s.length;    var ret = 0;    var pow = 1;    for (var i = len - 1; i >= 0; --i) {        ret += d[s[i]] * pow;        pow *= 26;    }    return ret;};

 

Excel Sheet Column Number