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 本质就是将一个26进制的数,转换成10进制的数
class Solution {
public int titleToNumber(String s) {
if(s == null && s.length() == 0){
return 0;
}
int len = s.length();
int sum = 0;
for(int i=0; i<len; i++){
int temp = s.charAt(i) - 'A'+ 1;
sum = sum * 26 + temp;
}
return sum;
}
}

Microsoft-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. jsp session/application

    session的增加读取 session.setAttribute("username", "张三"); String u = (String) session ...

  2. Python 运算符重载

    https://www.cnblogs.com/hotbaby/p/4913363.html

  3. English trip V1 - 5.That's Amazing! 棒极了! Teacher:Patrick Key: can or can't

    In this lesson you will learn to describe what people can do. 在本课中,您将学习如何描述人们可以做什么. STARTE drive a c ...

  4. Confluence 6 LDAP 高级设置

    启用嵌套组(Enable Nested Groups) 为嵌套组启用或禁用支持. 一些目录服务器能够允许你在一个组中定义另外一个组.在这种结构下的用户组称为用户组嵌套.嵌套组的配置能够让子用户组继承上 ...

  5. 用Javascript 实现倒计时

    用Javascript 实现倒计时<!DOCTYPE html> <html lang="en"> <head> <meta charse ...

  6. string类的用法笔记

    要想使用标准C++中string类,必须要包含 #include <string>// 注意是<string>,不是<string.h>,带.h的是C语言中的头文件 ...

  7. 此纳税人登记号已用于同一期间的交易方(交易方类型为 XXX 且交易方名称为 xxxx)。

    When updated Supplier's tax informations , System occurs a error:'This tax registration number is al ...

  8. 区别@ControllerAdvice 和@RestControllerAdvice

    @ControllerAdvice和@RestControllerAdvice都可以指向控制器的一个子集: // 指向所有带有注解@RestController的控制器 @ControllerAdvi ...

  9. jsp config设置jsp页面

    jsp-config jsp-config功能:用于设定jsp页面的相关设置(web.xml 版本在2.4之后) 常用的设置包括 taglib和jsp-property-group两个子元素.其中ta ...

  10. Our supersheet

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...