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 ...
随机推荐
- pycharm 里面引用pymysql
import pymysql db =pymysql.connect(host ='192.168.1.131',port=3306,user='jack',password ='jack',db = ...
- Egret中的三种单例写法
1 普通的单例写法 as3中也是这么个写法. 缺点:每个单例类里都要写instance和getInstance. class Single{ private static instance:Singl ...
- GDI+绘制半圆按钮
新建一个用户控件: public partial class UserControl1 : UserControl { public UserControl1() { InitializeCompon ...
- idea如何打war包?(部署tomcat后具有class文件)
- thinkphp---部署在IIS8.0服务器上
最近做了一个项目,使用的是我自己基于thinkphp开发的一套CMS,由于我本地使用的都是apche的环境,即使是线上环境用的也是宝塔面板,但是现在要将thinkphp的系统部署在IIS8.0的环境下 ...
- easyui_1
--- easyui.css包括所有组件的css,
- POJ-1975 Median Weight Bead(Floyed)
Median Weight Bead Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3162 Accepted: 1630 De ...
- 自动布局又出问题-HPPGCTableViewCell
[self.firstComment mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(sel ...
- linux中使用arcpy
切换到对应目录 即下图的 server安装路径 /home/arcgis/arcgis/server/tools 然后输入 ./python (这一步要注意 python这个命令 ...
- 看病要排队--hdu1873
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1873 运用优先队列写就行了 #include<stdio.h> #include< ...