当前位置:网站首页>力扣每日一题
力扣每日一题
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;
}
}边栏推荐
猜你喜欢
随机推荐
Hash these knowledge you should also know
Summary of Text Characterization Methods
Algorithm Supplements Fifteen Complementary Linked List Related Interview Questions
Mysql为什么 建立数据库失败
Mysql 死锁和死锁的解决方案
每月稳定干2万
Game Thinking 19: Multi-dimensional calculation related to games: point product, cross product, point-line-surface distance calculation
国家强制性灯具安全标准GB7000.1-2015
访问被拒绝:“microsoft.web.ui.webcontrols”的解决办法
Libpq 是否支持读写分离配置
[Tool Configuration] Summary of Common Uses of VSCode
re正则表达式
An IP conflict is reported after installing the software on a dedicated computer terminal
In the anaconda Promat interface, import torch is passed, and the error is reported in the jupyter notebook (only provide ideas and understanding!)
MAYA船的建模
browserslist 选项的目的是什么?
C# FileSystemWatcher
DeFi 前景展望:概览主流 DeFi 协议二季度进展
GAN生成动漫头像Pytorch
配合屏幕录像专家,又小又清晰!









