Skip to content

Instantly share code, notes, and snippets.

@RP-3
Created August 10, 2020 10:39
Show Gist options
  • Save RP-3/1d0e1e66a444c7e550f9af3890cba771 to your computer and use it in GitHub Desktop.
Save RP-3/1d0e1e66a444c7e550f9af3890cba771 to your computer and use it in GitHub Desktop.
import "math"
func titleToNumber(s string) int {
result := 0
l := len(s)
zero := 'A' - 1
for i := l - 1; i >= 0; i-- {
result += int(math.Pow(26, float64(l-i-1)) * float64((s[i] - byte(zero))))
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment