diff --git a/problems/excel-sheet-column-title/excel_sheet_column_title.go b/problems/excel-sheet-column-title/excel_sheet_column_title.go index 954d1d263..82cbd34ac 100644 --- a/problems/excel-sheet-column-title/excel_sheet_column_title.go +++ b/problems/excel-sheet-column-title/excel_sheet_column_title.go @@ -1,8 +1,8 @@ package excel_sheet_column_title func convertToTitle(n int) string { - if n < 27 { - return string(n - 1 + 'A') + if n--; n < 26 { + return string(n + 'A') } - return convertToTitle((n-1)/26) + string((n-1)%26+'A') + return convertToTitle(n/26) + string(n%26+'A') }