LeetCode:Excel Sheet Column Number

Posted walker lee

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode:Excel Sheet Column Number相关的知识,希望对你有一定的参考价值。

Excel Sheet Column Number




Total Accepted: 80221 Total Submissions: 190904 Difficulty: Easy

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 

Credits:
Special thanks to @ts for adding this problem and creating all test cases.

Subscribe to see which companies asked this question

Hide Tags
 Math
Hide Similar Problems
 (E) Excel Sheet Column Title


























c code:

int titleToNumber(char* s) {
    int size = strlen(s);
    int ret = 0;
    for(int i=0;i<size;i++) {
        ret = ret * 26 + s[i] - 'A' + 1;
    }
    return ret;
}


以上是关于LeetCode:Excel Sheet Column Number的主要内容,如果未能解决你的问题,请参考以下文章

[LeetCode] Excel Sheet Column Title

LeetCode Excel Sheet Column Title

LeetCode Excel Sheet Column Number

LeetCode Excel Sheet Column Number

LeetCode Excel Sheet Column Title

leetcode:Excel表列名称(详解)