aboutsummaryrefslogtreecommitdiff
path: root/Computer_Science/leetcode/58-length_of_last_word.c~
diff options
context:
space:
mode:
Diffstat (limited to 'Computer_Science/leetcode/58-length_of_last_word.c~')
-rw-r--r--Computer_Science/leetcode/58-length_of_last_word.c~13
1 files changed, 13 insertions, 0 deletions
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;
+}