171. Excel Sheet Column Number--LeetCode Record
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 {
func titleToNumber(s: String) -> Int {
var sum:Int = 0
var basic:Int = 1
for (index, ch) in String(s).unicodeScalars.enumerate().reverse() {
let chInt = Int(ch.value) - 64
sum += basic * chInt
basic *= 26
}
return sum
}
}
TestCase
"A"
"AB"
"BA"
"ABC"
"CAB"
相關文章
- Leetcode 171. Excel Sheet Column NumberLeetCodeExcel
- Excel Sheet Column Number Excel表列序號Excel
- Excel Sheet Column Title Excel表列名稱Excel
- [LeetCode] Excel Sheet Column NumberLeetCodeExcel
- leetcode刷題--Excel Sheet Column TitleLeetCodeExcel
- leetcode刷題--Excel Sheet Column NumberLeetCodeExcel
- Leetcode 168. Excel Sheet Column TitleLeetCodeExcel
- Leetcode168. Excel Sheet Column TitleLeetCodeExcel
- excel合併sheetExcel
- leetcode:171. Excel表列序號LeetCodeExcel
- 用Pandas讀寫Excel檔案-輸出單sheet和多sheetExcel
- fortune-sheet: 功能豐富的ReactJS線上Excel庫ReactJSExcel
- 多個報表匯出到一個 excel 的多 sheet 頁Excel
- Python合併多個Excel檔案中的指定sheetPythonExcel
- 【xiaomi】ASP.NET 分Sheet匯出EXCEL 2003ASP.NETExcel
- web 端如何像 excel 裡的多 sheet 方式呈現資料WebExcel
- 高效能javascript開源線上excel:x-sheet初體驗JavaScriptExcel
- 同一excel檔案中不同sheet間alt+tab切換Excel
- poi操作excel,複製sheet,複製行,複製單元格,複製styleExcel
- UNIX Quick Reference SheetUI
- 多個excel檔案合併到一個檔案中的多個sheet表中Excel
- 將多個實體類集合寫入同一個 Excel 檔案的不同 Sheet 頁Excel
- 使用Qt Style Sheet(1)QT
- react-recordReact
- Error: no such columnError
- 關於EasyExcel的資料匯入和單sheet和多sheet匯出Excel
- Git Cheat Sheet 中文版Git
- Axios 作弊表(Cheat Sheet)iOS
- Swift 4 Cheat Sheet AdvancedSwift
- Daily record-SeptemberAI
- Column Monitoring
- C#新增多個Sheet表C#
- ChatGPT Prompting Cheat Sheet備忘ChatGPT
- 實戰 Java 16 值型別 Record - 2. Record 的基本用法Java型別
- Index column size too large. The maximum column size is 767 bytesIndex
- Hibernate 註解@Column(nullable = false) 和 @Column(unique=true)NullFalse
- pl/sql record 詳解SQL
- delete duplication record in sql serverdeleteSQLServer