We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dd54252 commit 625b254Copy full SHA for 625b254
2018.12.3-leetcode58/Felix.md
@@ -0,0 +1,22 @@
1
+```javascript
2
+package leetcode.easy;
3
+/**
4
+ * @author Felix
5
+ * @date 2018年11月17日下午10:52:33
6
+ @version 给定一个仅包含大小写字母和空格 ' ' 的字符串,返回其最后一个单词的长度。
7
+如果不存在最后一个单词,请返回 0 。
8
+说明:一个单词是指由字母组成,但不包含任何空格的字符串。
9
+示例:输入: "Hello World" 输出: 5
10
+ */
11
+public class LengthOfLastWord {
12
+ public int lengthOfLastWord(String s) {
13
+ if(s == null || s.trim().length() == 0)
14
+ return 0;
15
+ String[] str = s.split(" ");
16
+ String res = str[str.length-1];
17
+
18
+ return res.length();
19
+ }
20
+}
21
22
+```
0 commit comments