leetcode: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 这题题目的意思就是:将26进制字母转化为10进制数字
class Solution {
public:
    int titleToNumber(string s) {
        int n=0;
        for(int i=0;i<s.size();i++)
        {
        n=n*26+(s[i]-‘A‘+1);
        return n;
        }
    }
};

  编译的时候开始总是出现

时间: 2024-10-08 05:16:29

leetcode:Excel Sheet Column Number的相关文章

leetcode——171 Excel Sheet Column Number (表格字母与整数的映射)

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 Hide Tags: M

leetcode:171 Excel Sheet Column Number-每日编程第十题

Excel Sheet Column Number Total Accepted: 54683 Total Submissions: 140674 Difficulty: Easy 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 -

LeetCode OJ: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 比较简单,类似进制的转换,代码如下: 1 class Solution {

【LeetCode】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 思路: 其实就是个进制转换.水水就过.倒是 Python 的代码让我

[LeetCode]61. Excel Sheet Column Number Excel列序号

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 addi

LeetCode: 171 Excel Sheet Column Number(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 代码: 1 class Solution { 2 public: 3

[C++]LeetCode: 116 Excel Sheet Column Number (excel列坐标转数字)

题目: 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 思路:这道题和Excel Sheet Column Title和是对

leetcode[171]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 class Solution { public: int titleToNu

[LeetCode][JavaScript]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 进制转换,比兄弟题简单. 1 /** 2 * @param {string}