func lengthOfLastWord(s string) int {
length := 0
tmpLength := 0
for _, item := range s {
if item == ' ' {
if tmpLength != 0 {
length = tmpLength
}
tmpLength = 0
continue
} else {
tmpLength++
}
}
if tmpLength != 0 {
length = tmpLength
}
return length
}
func lengthOfLastWord(s string) int {
arr := strings.Fields(s)
return len(arr[len(arr) - 1])
}