当前位置:网站首页>2022.08.04_每日一题
2022.08.04_每日一题
2022-08-05 11:48:00 【诺.い】
171. Excel 表列序号
题目描述
给你一个字符串 columnTitle ,表示 Excel 表格中的列名称。返回 该列名称对应的列序号 。
例如:
A -> 1
B -> 2
C -> 3
...
Z -> 26
AA -> 27
AB -> 28
...
示例 1:
输入: columnTitle = “A”
输出: 1
示例 2:
输入: columnTitle = “AB”
输出: 28
示例 3:
输入: columnTitle = “ZY”
输出: 701
提示:
1 <= columnTitle.length <= 7columnTitle仅由大写英文组成columnTitle在范围["A", "FXSHRXW"]内
coding
class Solution {
public int titleToNumber(String columnTitle) {
int x = 1;
int res = 0;
// 纯粹的进制转换
for(int i = columnTitle.length() - 1; i >= 0; i --) {
res += (columnTitle.charAt(i) - 'A' + 1) * x;
x *= 26;
}
return res;
}
}
边栏推荐
猜你喜欢
随机推荐
Http-Sumggling Cache Vulnerability Analysis
163_技巧_Power BI 一键批量建立自定义字段参数
有多一只“手”的机器狗出没?就在昇腾AI开发者创享日·南京站
Official release 2022 Nanjing Zhibo Expo is scheduled to be held in Xinzhuang National Exhibition in October
可视化开发必看:智慧城市四大核心技术
PHP高级检索功能的实现以及动态拼接SQL
“小钢炮”气质明显,安全、舒适一个不落
PMP每日一练 | 考试不迷路-8.5(包含敏捷+多选)
前沿技术数字孪生如何应用在智慧城市上?
el-menu箭头改为右下
莅临GOPS大会龙智展位,获取Forrester最新报告:《Forrester Wave:2021年第四季度企业服务管理报告》
手把手教你定位线上MySQL慢查询问题,包教包会
Android development with Kotlin programming language three loop control
祝所有码农七夕快乐~
我要抓狂了。。又回到了几天不能A一道题的时候
低代码平台开发有什么好处?
796. 子矩阵的和
How to write a blog with Golang - Milu.blog development summary
A woman is the most beautiful life in the world
广告电商系统









