ITPub博客

首页 > > > [LeetCode] Excel Sheet Column Number

[LeetCode] Excel Sheet Column Number

作者:Ruiyuan Li 时间:2015-04-11 00:00:00 0 删除 编辑

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

解题思路:

看成是进制转化的问题,这个是26进制转化成10进制。比较简单,代码如下:

class Solution {
public:
    int titleToNumber(string s) {
        int len=s.length();
        if(len==0){
            return 0;
        }
        int result = 0;
        for(int i=0; i

二次刷题(2015-08-06)

class Solution {
public:
    int titleToNumber(string s) {
        int result = 0;
        int len = s.length();
        for(int i=0; i


<!-- -->

原文作者:;如有侵权,请联系管理员删除。

请登录后发表评论 登录
全部评论

注册时间:2020-05-21

  • 博文量
    495
  • 访问量
    4824