leetcode 171
171. Excel Sheet Column Number
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,按照26进制进位。
代码如下:
class Solution {
public:
int titleToNumber(string s) {
int n = s.length();
int m = n;
int result = ;
if(n == )
{
return ;
}
result = (int)s[m-];
result -= ;
for(int i = ; i < n+; i++)
{
m--;
if(m == )
{
return result;
}
int p = ;
for(int j = ; j < i; j++)
{
p *= ;
}
int re = (int)s[m-];
re -= ;
result = result + re * p;
}
return result;
}
};
leetcode 171的更多相关文章
- LeetCode 171. Excel表列序号(Excel Sheet Column Number) 22
171. Excel表列序号 171. Excel Sheet Column Number 题目描述 给定一个 Excel 表格中的列名称,返回其相应的列序号. 每日一算法2019/5/25Day 2 ...
- Leetcode 171 Excel Sheet Column Number 难度:0
https://leetcode.com/problems/excel-sheet-column-number/ class Solution { public: int titleToNumber( ...
- LeetCode 171. Excel Sheet Column Number (Excel 表格列数字)
Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, retur ...
- [LeetCode] 171. Excel Sheet Column Number 求Excel表列序号
Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, retur ...
- Java实现 LeetCode 171 Excel表列序号
171. Excel表列序号 给定一个Excel表格中的列名称,返回其相应的列序号. 例如, A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> ...
- ✡ leetcode 171. Excel Sheet Column Number 字母转换为数字 --------- java
Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, retur ...
- LeetCode 171 Excel Sheet Column Number
Problem: Given a column title as appear in an Excel sheet, return its corresponding column number. F ...
- Java for LeetCode 171 Excel Sheet Column Number
Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, retur ...
- Java [Leetcode 171]Excel Sheet Column Number
题目描述: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 解题思路: 循环读取数字,从左向右读取,每次该位字 ...
随机推荐
- [转]使用Maven添加依赖项时(Add Dependency)时,没有提示项目可用,并且在Console中,输出: Unable to update index for central|http://repo1.maven.org/maven2 。
使用Maven添加依赖项时(Add Dependency)时,没有提示项目可用,并且在Console中,输出: Unable to update index for central|http://re ...
- 移动web
1.分辨率 1900*1200这就是一个分辨率, 因为pt的存在,因此还会有一个逻辑分辨率的概念 2.ppi = pixels per inch这里inch不是平方英尺,是英尺 3.dp = devi ...
- python-program
程序需要一步步改进,解决bug,尽量从源头判断,并给出处理措施. 1.客户端执行一次,程序就退出, 2.客户端空值,错误命令,程序会死掉 3.收发缓冲区大小,即recv(1024)的问题,如果收一个1 ...
- t2712:字符串移位包含问题
t2712:字符串移位包含问题 总时间限制:1000ms 内存限制:65536kB描述 给定两个字符串s1和s2,要求判定其中一个字符串 是否是另一字符串通过循环移位后的子字符串.例 ...
- [Linux] - CentOS中文乱码解决办法
CentOS 7 终端中文乱码解决办法: 1.使用vim编辑locale.config文件: vim /etc/locale.conf 2.将LANG="en_US.UTF-8"修 ...
- LeetCode "Wiggle Subsequence" !
Another interesting DP. Lesson learnt: how you define state is crucial.. 1. if DP[i] is defined as, ...
- Android AChartEngine 饼图渐变效果
二话不说,先上图 核心代码如下: private void initLabelChat(View rootView) { NumberFormat nf = new DecimalFormat(&qu ...
- Shiro简单配置
注:这里只介绍Spring配置模式. 因为官方例子虽然中有更加简洁的ini配置形式,但是使用ini配置无法与spring整合.而且两种配置方法一样,只是格式不一样. 涉及的jar包 核心包shiro- ...
- Best Practices for Performance_1、2 memory、Tips 性能和小的优化点、 onTrimMemory
http://developer.android.com/training/articles/memory.htmlhttp://developer.android.com/tools/debuggi ...
- Elasticsearch mysql 增量同步 三表联合 脚本
在上一篇中简略的说了一下es同步数据脚本的大致情况,但是实际情况里肯定不会像上一篇里面的脚本那么简单.比如目前我就有三张表,两张实体表,一张关联表.大致实现如下: bin目录建立一个statefile ...