LeetCode: 171 Excel Sheet Column Number(easy)
2024-10-20 05:21:12
题目:
Related to question Excel Sheet Column Title
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
代码:
class Solution {
public:
int titleToNumber(string s) {
map<char, int> map;
int num = ;
int result = ;
for (char i = 'A'; i<='Z'; i++){
map[i] = num;
num++;
}
int j = ;
for(auto c = s.crbegin(); c<s.crend(); c++){
result = map[*c]*pow(, j) + result;
j++;
} return result;
}
};
最新文章
- PHP玩转微信公众平台自定义接口
- docker 1.8+之后ubuntu安装指定版本docker-engine
- qq邮箱邮我组件
- 【BZOJ】2321: [BeiJing2011集训]星器(数学+特殊的技巧)
- Java Swing 探索(一)LayoutManager
- 可视化Windows服务定时任务
- UNIX标准化及实现之标准之间的冲突
- url中的jsessionid解释
- 【转】JDBC学习笔记(1)——JDBC概述
- asp.net core系列 61 Ocelot 构建服务发现简单示例
- leetcode-217存在重复元素
- Maven的日常
- Vue.js路由
- 简单rmi示例
- MySQL RR模式下如何加锁
- Vivado抓取信号
- Python六大开源框架对比:Web2py略胜一筹(转)
- 20145333茹翔 Exp5 Adobe阅读器漏洞攻击
- jQuery 中的编程范式
- 【bzoj3203】[Sdoi2013]保护出题人 凸包+二分
热门文章
- LINQ 学习路程 -- 查询操作 Average Count Max Sum
- Luogu P1196 [NOI2002]银河英雄传说:带权并查集
- 十大最流行PHP框架排名
- 006-完全关闭win任务栏鼠标悬停预览
- Java进阶08 GUI
- CCSpriteBatchNode CCSpriteFrameCache
- CodeForces - 1C:Ancient Berland Circus (几何)
- 洛谷P2895 [USACO08FEB]流星雨Meteor Shower
- InvalidOperationException: out of sync
- 逐步改用 IronPython 开发你的 ASP.NET 应用程序