Created
August 11, 2021 18:43
-
-
Save r14152/4e4a6f421d689bb1ff4d771c8707274b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import( | |
"strings" | |
"fmt" | |
) | |
func lengthOfLastWord(s string) int { | |
str := strings.Split(s," ") | |
for j:= len(str)-1;j>=0;j--{ | |
if str[j] == ""{ | |
continue | |
} | |
return len(str[j]) | |
} | |
return len(str) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment