当前位置:网站首页>力扣每日一题
力扣每日一题
2022-08-05 07:31:00 【小唐学姐】
给你一个字符串 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 <= 7
columnTitle 仅由大写英文组成
columnTitle 在范围 ["A", "FXSHRXW"] 内
来源:力扣(LeetCode)
链接:https://leetcode.cn/problems/excel-sheet-column-number
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
class Solution {
public int titleToNumber(String s) {
int res=0;
int len=s.length();
int i=0;
while(i<len){
res*=26;
res+=(s.charAt(i)-'A')+1;
i++;
}
return res;
}
}边栏推荐
- Tencent Business Security Post IDP Talk Summary
- Flink Learning 10: Use idea to write WordCount and package and run
- 2022.8.2 模拟赛
- uniapp time component encapsulates year-month-day-hour-minute-second
- TRACE32——Break
- Put Cloudflare on the website (take Tencent Cloud as an example)
- 线性代数对角化
- Liunx教程超详细(完整)
- 配合屏幕录像专家,又小又清晰!
- MySQL:连接查询 | 内连接,外连接
猜你喜欢

Summary of Text Characterization Methods

3555. 二叉树

Falsely bamboo brother today and found a localization of API to use tools

Flink Learning 10: Use idea to write WordCount and package and run

Algorithm Supplements Fifteen Complementary Linked List Related Interview Questions

VXE-Table融合多语言

Redis数据库学习

在anaconda Promat界面import torch通过,在jupyter notebook中报错的问题(仅提供思路理解!)

TCP sticky packet unpacking problem + solution

MAYA船的建模
随机推荐
Task flow scheduling tool AirFlow,, 220804,,
re正则表达式
本地能ping通虚拟机,虚拟机ping不通本地
Win10 设置锁屏壁纸提示尝试其它图片
ARM Cortex-M上的Trace跟踪方案
MobileNetV1架构解析
Illegal key size 报错问题
Bluetooth gap protocol
TRACE32——Break
U++ 创建UI
外企Office常用英语
SVG星球大战样式Toggle切换开关按钮
Hash 这些知识你也应该知道
字符串提取 中文、英文、数字
Redis常用命令
对数据类型而言运算符无效。运算符为 add,类型为 text。
Tencent Internship Summary
Does Libpq support read-write separation configuration?
配合屏幕录像专家,又小又清晰!
青苹果论坛重新开放