mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-05 00:25:22 +08:00
11 lines
168 B
Go
11 lines
168 B
Go
package leetcode
|
|
|
|
func titleToNumber(s string) int {
|
|
val, res := 0, 0
|
|
for i := 0; i < len(s); i++ {
|
|
val = int(s[i] - 'A' + 1)
|
|
res = res*26 + val
|
|
}
|
|
return res
|
|
}
|