add new solutions
This commit is contained in:
parent
59b71480d4
commit
71189b61cf
8 changed files with 200 additions and 0 deletions
13
solutions/0/q58/solution.go
Normal file
13
solutions/0/q58/solution.go
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package q58
|
||||
|
||||
func lengthOfLastWord(s string) int {
|
||||
i := len(s)
|
||||
for ; s[i-1] == ' '; i-- {
|
||||
}
|
||||
j := i - 1
|
||||
for ; j > 0 && s[j-1] != ' '; j-- {
|
||||
}
|
||||
return i - j
|
||||
}
|
||||
|
||||
var _ = lengthOfLastWord
|
||||
Loading…
Add table
Add a link
Reference in a new issue