Skip to content

Commit 6d2ccef

Browse files
author
Shuo
authored
Merge pull request #399 from openset/develop
Update: Excel Sheet Column Title
2 parents df85dd0 + e8cfc26 commit 6d2ccef

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package excel_sheet_column_title
22

33
func convertToTitle(n int) string {
4-
if n < 27 {
5-
return string(n - 1 + 'A')
4+
if n--; n < 26 {
5+
return string(n + 'A')
66
}
7-
return convertToTitle((n-1)/26) + string((n-1)%26+'A')
7+
return convertToTitle(n/26) + string(n%26+'A')
88
}

0 commit comments

Comments
 (0)