Skip to content

Commit f37e7a9

Browse files
authored
Create Sunny.md
1 parent fca637a commit f37e7a9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

2018.12.3-leetcode58/Sunny.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
```java
2+
class Solution {
3+
public int lengthOfLastWord(String s) {
4+
if (s == null) return 0;
5+
int i = s.lastIndexOf(" ");
6+
if (i < 0) return s.length();
7+
if (i == (s.length() - 1) && s.length() > 1) {
8+
s = s.substring(0, i);
9+
return lengthOfLastWord(s);
10+
}
11+
return s.substring(i+1, s.length()).length();
12+
}
13+
}
14+
```

0 commit comments

Comments
 (0)