LeetCode 171. 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進位制。
Code:
class Solution { public: int titleToNumber(string s) { int ans=0; int len=s.size(); for(int i=len;i>0;i--){ ans+=(s[i-1]-'A'+1)*pow(26,len-i); } return ans; } };
相關推薦
LeetCode 171. 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
LeetCode 171. 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
LeetCode: 171 Excel Sheet Column Number(easy)
pre 代碼 turn har nbsp sheet tps -s https 題目: Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet
leetcode 171. Excel Sheet Column Number
return pan div let () col 記得 excel .net 這個題其實是做26進制轉換 這個地方記得減大A,不是小a class Solution { public: int titleToNumber(string s) {
LeetCode 171.Excel Sheet Column Number (Excel表列序號)
題目描述: 給定一個Excel表格中的列名稱,返回其相應的列序號。 例如, A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 ...
LeetCode 171 Excel Sheet Column Number(Excel的列向表數字)
翻譯 給定一個出現在Excel表格上的列表標題,返回它的正確行數。 例如: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB
Leetcode——171. Excel Sheet Column Number
題目原址 題目描述 Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1
python leetcode 168. Excel Sheet Column Title 171. Excel Sheet Column Number
168. Excel Sheet Column Title class Solution: def convertToTitle(self, n): """ :type n: int :rtype: str """
171. Excel Sheet Column Number Leetcode Python
Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. Fo
171. Excel Sheet Column Number (Easy)
cnblogs appear color bsp return style nbsp def log Given a column title as appear in an Excel sheet, return its corresponding column numb
171 Excel Sheet Column Number Excel表列序號
string public highlight des excel表格 log return tco tps 給定一個Excel表格中的列名稱,返回其相應的列序號。示例: A -> 1 B -> 2 C -> 3 ... Z
171. Excel Sheet Column Number Excel表格的字母轉成數字
turn ear 輸出 其他 ber eight 思路 exit span [抄題]: Given a column title as appear in an Excel sheet, return its corresponding column number. For
171. Excel Sheet Column Number
appear 每次 ret str ash dict hash 公式 put 171. Excel Sheet Column Number Given a column title as appear in an Excel sheet, return its corres
LeetCode-171.Excel Sheet Colunm Number
Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3
LeetCode 169 Excel Sheet Column Number Excel表列序號
26進位制轉10進位制,注意以'A'而不是0開頭,因此要“+1” 解法一: class Solution { public: int titleToNumber(string s) { int n = s.size(); int r
leetcode (Excel Sheet Column Number)
Title:Excel Sheet Column Number 171 Difficulty:Easy 原題leetcode地址: https://leetcode.com/problems/excel-sheet-column-numb
[LeetCode] Excel Sheet Column Number
-- += cor span ... num urn respond 累加 Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, retu
LeetCode[Math]----Excel Sheet Column Title----Excel Sheet Column Number
Excel Sheet Column Title Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1 -&
leetcode Excel Sheet Column Number
Excel Sheet Column Number 題目:https://leetcode.com/problems/excel-sheet-column-numbe 把excel表格的列轉化為10進位制的數,本質相當於把26進位制的數轉化為10進位制的數。 public static vo
LeetCode-Excel Sheet Column Number
Description: Given a column title as appear in an Excel sheet, return its corresponding column number