Files
LeetCode-Go/leetcode/0168.Excel-Sheet-Column-Title/168. Excel Sheet Column Title.go
2020-08-12 20:12:33 +08:00

14 lines
285 B
Go

package leetcode
func convertToTitle(n int) string {
result := []byte{}
for n > 0 {
result = append(result, 'A'+byte((n-1)%26))
n = (n - 1) / 26
}
for i, j := 0, len(result)-1; i < j; i, j = i+1, j-1 {
result[i], result[j] = result[j], result[i]
}
return string(result)
}