[Algorithm] 171. Excel Sheet Column Number
Excel number Column ALGORITHM sheet
2023-09-14 08:59:14 时间
Given a column title as appear in an Excel sheet, return its corresponding column number.
For example:
A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ...Example 1:
Input: "A" Output: 1Example 2:
Input: "AB" Output: 28Example 3:
Input: "ZY" Output: 701
Basiclly, it is 26-based, the same as 10-based,
102 = 1 + 1
previous result * 10 + 0 + 1*10+0=10
previous result * 10 +2 + 10*10+2=102
AAA =
1 +
1 * 26 +1
27 * 26 + 1 = 703
/** * @param {string} s * @return {number} */ var titleToNumber = function(s) { if (!s) { return 0; } let sum = 0; let len = s.length; for (let i = 0; i < len; i++) { sum = sum * 26 + (s[i].charCodeAt() - 64); } return sum; };
相关文章
- Excel操作-用excel实现爬取网站上表格数据
- Office EXCEL 不用VB,你也可以制作自己的Excel菜单!
- 使用POI生成Excel文件,可以自动调整excel列宽
- Python导出DBF文件到Excel的方法
- Excel公式的常见错误值及其解决方法
- excel怎么设置密码保护?Excel文件添加密码保护教程
- 微软 Excel 365 里如何设置下拉菜单和自动高亮成指定颜色
- C# Excel数据验重及Table数据验重
- Atitit.office word excel ppt pdf 的web在线预览方案与html转换方案 attilax 总结
- Stellar Repair for Excel 6.0.1 Crack
- Qt玩转Excel
- 100天精通Python(数据分析篇)——第57天:Pandas读写Excel(read_excel、to_excel参数说明+代码实战)
- 〖Python自动化办公篇⑫〗- Excel 文件自动化 - 读取 excel 数据
- 〖Python自动化办公篇⑬〗- Excel 文件自动化 - 写入 excel 数据(xlsxwriter)
- excel sumif函数拖动的问题
- python xml转excel
- excel根据颜色赋值 Excel填充颜色单元格替换成数字 excel把所有红色变成1
- 玩转excel===Excel处理txt文件中的数据,Excel中的分列处理
- JAVA操作Excel表格:方法一:jxl的使用②:Excel实战之JXL解析读取excel文件
- JAVA操作Excel表格:方法一:jxl的使用①:Excel实战之JXL创建excel文件
- springboot使用jxls导出excel___(万能通用模板)--- SpringBoot导入、导出Excel文件___SpringBoot整合EasyExcel模板导出Excel