Excel Sheet Column Number

时间:2022-02-24 23:11:17

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) {
auto it = s.end()-;
char c;
int num =;
int i=;
while(it>=s.begin()) {
c = *it;
num += (c-'A'+)*i;
i *= ;
--it;
}
return num;
}
};

模仿整数的操作即可。

Excel Sheet Column Number的更多相关文章

  1. 【leetcode】Excel Sheet Column Title & Excel Sheet Column Number

    题目描述: Excel Sheet Column Title Given a positive integer, return its corresponding column title as ap ...

  2. Excel Sheet Column Title & Excel Sheet Column Number

    Excel Sheet Column Title Given a positive integer, return its corresponding column title as appear i ...

  3. 【leetcode】Excel Sheet Column Number

    Excel Sheet Column Number Related to question Excel Sheet Column Title Given a column title as appea ...

  4. 【LeetCode】168 & 171- Excel Sheet Column Title & Excel Sheet Column Number

    168 - Excel Sheet Column Title Given a positive integer, return its corresponding column title as ap ...

  5. 171. Excel Sheet Column Number(C++)

    171. Excel Sheet Column Number Related to question Excel Sheet Column Title Given a column title as ...

  6. 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; ...

  7. 2016.5.18——Excel Sheet Column Number

    Excel Sheet Column Number 本题收获: 1.对于字符串中字母转为ASIIC码:string s ;res = s[i]-'A'; 这个res就是数字s[i]-'A'是对ASII ...

  8. leetcode 168. Excel Sheet Column Title 171 Excel Sheet Column Number

    题目 //像10进制一样进行 转换   只是要从0开始记录 class Solution { public: string convertToTitle(int n) { char a; string ...

  9. Excel Sheet Column Title&&Excel Sheet Column Number

    Excel Sheet Column Title Given a positive integer, return its corresponding column title as appear i ...

  10. LeetCode Excel Sheet Column Number 表列数

    题意:天啊!我竟然看不懂题意,还去翻别人的代码才懂!给定一个字符串,求该字符串二十六进制的总值. 思路:'A'~'Z'就是1到26,"AA"=26+1=27,"BA&qu ...

随机推荐

  1. ORACLE数据库汉字占几个字节问题

    一同事由于系统需求关系,将SQL SERVER数据库的一个表导入ORACLE数据库时,发现居然报错:ORA-12899: value too large for column xxxx (actual ...

  2. Codeforces Round #250 (Div. 2) A. The Child and Homework

    注意题目长度不能考虑前缀,而且如果即存在一个选项的长度的两倍小于其他所有选项的长度,也存在一个选项的长度大于其他选项长度的两倍,则答案不是一个好的选择,只能选择C. #include <iost ...

  3. 对C&plus;&plus;下struct 和 类默认继承的认识

    #include <iostream> using namespace std; struct struct1{ int data1 ; double data2 ; struct1(){ ...

  4. Android 各种MIME类型和文件类型的匹配表

    MIME:全称Multipurpose Internet Mail Extensions,多功能Internet 邮件扩充服务.它是一种多用途网际邮件扩充协议,在1992年最早应用于电子邮件系统,但后 ...

  5. cf478D Red-Green Towers

    D. Red-Green Towers time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  6. 最新版Charles破解方法&lpar;Mac&plus;Windows&rpar;&period;md

    Charles 破解 去网站 http://charles.iiilab.com/ 下载相对应的版本 下载破解文件 charles.jar http://charles.iiilab.com/ 替换掉 ...

  7. java线程阻塞唤醒的四种方式

    java在多线程情况下,经常会使用到线程的阻塞与唤醒,这里就为大家简单介绍一下以下几种阻塞/唤醒方式与区别,不做详细的介绍与代码分析 suspend与resume Java废弃 suspend() 去 ...

  8. node&period;js安装全攻略

    node.js学习也有近一年之久了,自开始以来,能遇到各种问题,就拿安装来说,总能遇到稀奇古怪的问题,但每次谷歌,或者百度,都能找到解决办法,逐渐也就养成了百度或者谷歌的毛病! 正常安装 第一步:下载 ...

  9. css学习&lowbar;css复合选择器

    css复合选择器 a.交集选择器  (即...又...:选择器之间不能有空格) p.one{color:red;] b.并集选择器(中间由逗号隔开) p,div{color:red;} c.后代选择器 ...

  10. MySQL root账户密码设为&OpenCurlyDoubleQuote;root”后执行命令提示ERROR 1820 &lpar;HY000&rpar;&colon; You must reset your password using ALTER USER statement before executing this statement&period;

    修改root账户密码为“root”后,提示ERROR 1820 (HY000): You must reset your password using ALTER USER statement bef ...