第十二周leetcode题
来源:互联网 发布:mp3统一音量软件 编辑:程序博客网 时间:2024/06/05 20:19
Description:
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
题目给出的字母组合可以看成是二十七进制数,字母A到Z分别代表1到26,像计算其他进制的数一样计算结果即可。代码如下:
class Solution {
public:
int titleToNumber(string s) {
int a=s.length();
int re=0;
for(int i=0;i<a;i++)
{
re+=pow(26, a-i-1)*(s[i]-'A'+1);
}
return re;
}
};
阅读全文
0 0
- 第十二周leetcode题
- leetcode-python 第十二周
- leetcode-第十二周
- 第十二周LeetCode
- 第十二周LeetCode
- 第十二周LeetCode
- LeetCode题解 第十二周
- leetcode【第十二周】简化路径
- 第十二周LeetCode算法题三道
- Leetcode 算法习题 第十二周
- 第十二周:[leetCode] 152. Maximum Product Subarray
- leetcode第十二周解题总结--动态规划
- Leetcode 第十二题 Integer to Roman
- 每天一题LeetCode[第十二天]
- 第十二周 leetcode 207. Course Schedule(Medium)
- 第十二周
- 第十二周
- 第十二周
- Deep Learning 最优化方法之SGD
- oracle 11g 和pl/sql安装时的小问题
- springboot-01工程搭建
- Linux基础(5)
- poj 1269 Intersecting Lines
- 第十二周leetcode题
- ubuntu环境源码安装git服务
- 闭包
- Linux -二-主机映射、Xshell安装(20170515)
- 深度学习中卷基层和全连接层训练参数个数如何确定
- POJ3616-Milking Time
- (59)组件之缆绳组件
- Java大白话—–Token入门案例(附demo下载)
- 算法设计作业12