171. Excel Sheet Column Number(简单数学题)
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
...
Example 1:
Input: "A"
Output: 1
Example 2:
Input: "AB"
Output: 28
Example 3:
Input: "ZY"
Output: 701
class Solution {
public int titleToNumber(String s) {
int result = 0;
int i = 0;
while(i < s.length()){
result = result * 26 + (s.charAt(i) - 'A' + 1);
i++;
}
return result;
}
}
171. Excel Sheet Column Number(简单数学题)的更多相关文章
- LeetCode Javascript实现 100. Same Tree 171. Excel Sheet Column Number
100. Same Tree /** * Definition for a binary tree node. * function TreeNode(val) { * this.val = val; ...
- 171. Excel Sheet Column Number(C++)
171. Excel Sheet Column Number Related to question Excel Sheet Column Title Given a column title as ...
- leetcode 168. Excel Sheet Column Title 171 Excel Sheet Column Number
题目 //像10进制一样进行 转换 只是要从0开始记录 class Solution { public: string convertToTitle(int n) { char a; string ...
- ✡ 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 ...
- 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 ...
- 【LeetCode】171. Excel Sheet Column Number
题目: Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, r ...
- 171. Excel Sheet Column Number (Math)
Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, retur ...
- LeetCode: 171 Excel Sheet Column Number(easy)
题目: Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, r ...
- 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 ...
随机推荐
- [Sdoi2016]生成魔咒[SAM or SA]
4516: [Sdoi2016]生成魔咒 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1017 Solved: 569[Submit][Statu ...
- SSH使用秘钥和别名登陆服务器
手工配置免密码及别名登陆 第一步:生成秘钥 $ ssh-keygen -t rsa 第二步:上传公钥到目标服务器 $ ssh-copy-id -i ~/.ssh/id_rsa.pub <romt ...
- 【CF736D】Permutations 线性代数+高斯消元
[CF736D]Permutations 题意:有一个未知长度为n的排列和m个条件,第i个条件$(a_i,b_i)$表示第$a_i$个位置上的数可以为$b_i$.保证最终合法的排列的个数是奇数.现在有 ...
- UEditor富文本WEB编辑器自定义默认值设置方法
1.在使用UEditor编辑器编写内容时你会发现,当输入的内容较多时,编辑框的边框高度也会自动增加,若希望输入内容较多时以拉框滚动的效果. 方法:找到Ueditor文件根目录下的ueditor.con ...
- wpgcms---单片页数据渲染
单片页数据渲染,使用Twig的标签语法: <h1> {{ contentInfo.title }} </h1> {% autoescape false %} {{ conten ...
- Spark2 Dataset分析函数--排名函数row_number,rank,dense_rank,percent_rank
select gender, age, row_number() over(partition by gender order by age) as rowNumber, ...
- Logstash在Linux上安装部署
Logstash 简介: Logstash 是一个实时数据收集引擎,可收集各类型数据并对其进行分析,过滤和归纳.按照自己条件分析过滤出符合数据导入到可视化界面.它可以实现多样化的数据源数据全量或增量传 ...
- 2018牛客网暑期ACM多校训练营(第三场) A - PACM Team - [四维01背包][四约束01背包]
题目链接:https://www.nowcoder.com/acm/contest/141/A 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524288K ...
- Spyer中添加一些常用包的方法
我用的是Anaconda中的Spyer编译,在导入包pyaudio时,发现找不到,需要手工导入.可以打开Anacoda promt,查看已经安装的包名用:pip list Spyer中的所有包在这里安 ...
- 【紫书】【重要】Abbott's Revenge UVA - 816 bfs 复杂模拟 带方向参数的迷宫
题意:一个迷宫,每个交叉路口有一路标,限制了你从某方向进入该路口所能进入的路口. 题解:1.对于方向的处理:将node多增加一维dir,通过一个const 字符数组 加 上dir_id函数 以及一个方 ...