Skip to content

Commit 4ebab0d

Browse files
committed
finish 0058
1 parent da18d19 commit 4ebab0d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ since 2021.10.10 / Benben
2929
- 0028.Implement strStr()
3030
- 0035.Search Insert Position
3131
- 0053.Maximum SubArray
32+
- 0058.Length of Last Word
3233
- 0104.Maximum Depth of Binary Tree
3334
- 0100.Same Tree
3435
- 0110.Balanced Binary Tree
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @param {string} s
3+
* @return {number}
4+
*/
5+
var lengthOfLastWord = function(s) {
6+
const arr = s.trim().split(' ')
7+
return arr[arr.length - 1].length
8+
};
9+
10+
// 2022/06/13 done
11+
// Runtime: 61 ms, faster than 90.52% of JavaScript online submissions for Length of Last Word.
12+
// Memory Usage: 42.5 MB, less than 9.29% of JavaScript online submissions for Length of Last Word.

0 commit comments

Comments
 (0)