From 79a9c52fa923fc78074d88463449a8b7f95ca3ef Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Tue, 26 Dec 2017 01:33:40 +0800 Subject: update leetcode solution --- Computer_Science/leetcode/58-length_of_last_word.c~ | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Computer_Science/leetcode/58-length_of_last_word.c~ (limited to 'Computer_Science/leetcode/58-length_of_last_word.c~') diff --git a/Computer_Science/leetcode/58-length_of_last_word.c~ b/Computer_Science/leetcode/58-length_of_last_word.c~ new file mode 100644 index 0000000..4b9e63b --- /dev/null +++ b/Computer_Science/leetcode/58-length_of_last_word.c~ @@ -0,0 +1,13 @@ +int lengthOfLastWord(char* s) { + char* space; + while(*s == ' ') + s++; + + space = s; + while(*s != '\0') { + if(*s == ' ') + space = s; + } + + return s - space; +} -- cgit v1.2.3