Skip to content

Commit f9609aa

Browse files
committed
excel_sheet_column_number
1 parent d3dcd82 commit f9609aa

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ Golang solution for leetcode. For each problem, there is a simple *_test.go to t
147147
#### [167. Two Sum II](https://github.com/hitzzc/go-leetcode/tree/master/two_sum_II)
148148
#### [168. Excel Sheet Column Title](https://github.com/hitzzc/go-leetcode/tree/master/excel_sheet_column_title)
149149
#### [169. Majority Element](https://github.com/hitzzc/go-leetcode/tree/master/majority_element)
150+
#### [171. Excel Sheet Column Number](https://github.com/hitzzc/go-leetcode/tree/master/excel_sheet_column_number)
150151

151152

152153

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package excel_sheet_column_number
2+
3+
func titleToNumber(s string) int {
4+
bytes := []byte(s)
5+
var ret int
6+
for i := range bytes {
7+
ret = 26*ret + int(bytes[i]-'A'+1)
8+
}
9+
return ret
10+
}

0 commit comments

Comments
 (0)