Skip to content

Commit 71b771d

Browse files
committed
Add solution 0058
1 parent 0d3b705 commit 71b771d

File tree

5 files changed

+59
-10
lines changed

5 files changed

+59
-10
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,16 @@
126126

127127
| | Easy | Medium | Hard | Total |
128128
|:--------:|:--------:|:--------:|:--------:|:--------:|
129-
|Optimizing|34|40|31|105|
129+
|Optimizing|33|40|31|104|
130130
|Accepted|**284**|**414**|**124**|**822**|
131131
|Total|517|1061|426|2004|
132-
|Perfection Rate|88.0%|90.3%|75.0%|87.2%|
132+
|Perfection Rate|88.4%|90.3%|75.0%|87.3%|
133133
|Completion Rate|54.9%|39.0%|29.1%|41.0%|
134134
|------------|----------------------------|----------------------------|----------------------------|----------------------------|
135135

136136
## 二. 目录
137137

138-
以下已经收录了 719 道题的题解,还有 11 道题在尝试优化到 beats 100%
138+
以下已经收录了 720 道题的题解,还有 11 道题在尝试优化到 beats 100%
139139

140140
| No. | Title | Solution | Acceptance | Difficulty | Frequency |
141141
|:--------:|:--------------------------------------------------------------|:--------:|:--------:|:--------:|:--------:|
@@ -196,7 +196,7 @@
196196
|0055|Jump Game|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0055.Jump-Game)|36.2%|Medium||
197197
|0056|Merge Intervals|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0056.Merge-Intervals)|42.8%|Medium||
198198
|0057|Insert Interval|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0057.Insert-Interval)|36.4%|Medium||
199-
|0058|Length of Last Word||34.4%|Easy||
199+
|0058|Length of Last Word|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0058.Length-of-Last-Word)|34.4%|Easy||
200200
|0059|Spiral Matrix II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0059.Spiral-Matrix-II)|59.8%|Medium||
201201
|0060|Permutation Sequence|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0060.Permutation-Sequence)|40.7%|Hard||
202202
|0061|Rotate List|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0061.Rotate-List)|32.8%|Medium||
@@ -365,7 +365,7 @@
365365
|0224|Basic Calculator|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0224.Basic-Calculator)|39.3%|Hard||
366366
|0225|Implement Stack using Queues|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0225.Implement-Stack-using-Queues)|49.8%|Easy||
367367
|0226|Invert Binary Tree|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0226.Invert-Binary-Tree)|69.0%|Easy||
368-
|0227|Basic Calculator II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0227.Basic-Calculator-II)|39.6%|Medium||
368+
|0227|Basic Calculator II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0227.Basic-Calculator-II)|39.7%|Medium||
369369
|0228|Summary Ranges|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0228.Summary-Ranges)|43.8%|Easy||
370370
|0229|Majority Element II|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0229.Majority-Element-II)|40.3%|Medium||
371371
|0230|Kth Smallest Element in a BST|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0230.Kth-Smallest-Element-in-a-BST)|64.6%|Medium||
@@ -1009,7 +1009,7 @@
10091009
|0868|Binary Gap||61.5%|Easy||
10101010
|0869|Reordered Power of 2|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0869.Reordered-Power-of-2)|61.2%|Medium||
10111011
|0870|Advantage Shuffle|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0870.Advantage-Shuffle)|50.9%|Medium||
1012-
|0871|Minimum Number of Refueling Stops||35.0%|Hard||
1012+
|0871|Minimum Number of Refueling Stops||35.1%|Hard||
10131013
|0872|Leaf-Similar Trees|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0872.Leaf-Similar-Trees)|64.7%|Easy||
10141014
|0873|Length of Longest Fibonacci Subsequence||48.5%|Medium||
10151015
|0874|Walking Robot Simulation|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/0874.Walking-Robot-Simulation)|37.0%|Easy||
@@ -1182,7 +1182,7 @@
11821182
|1041|Robot Bounded In Circle||54.7%|Medium||
11831183
|1042|Flower Planting With No Adjacent||49.2%|Medium||
11841184
|1043|Partition Array for Maximum Sum||69.1%|Medium||
1185-
|1044|Longest Duplicate Substring||30.7%|Hard||
1185+
|1044|Longest Duplicate Substring||30.6%|Hard||
11861186
|1045|Customers Who Bought All Products||67.6%|Medium||
11871187
|1046|Last Stone Weight||62.6%|Easy||
11881188
|1047|Remove All Adjacent Duplicates In String|[Go](https://github.com/halfrost/LeetCode-Go/tree/master/leetcode/1047.Remove-All-Adjacent-Duplicates-In-String)|71.3%|Easy||
@@ -2086,7 +2086,7 @@
20862086
|1945|Sum of Digits of String After Convert||62.0%|Easy||
20872087
|1946|Largest Number After Mutating Substring||33.1%|Medium||
20882088
|1947|Maximum Compatibility Score Sum||57.6%|Medium||
2089-
|1948|Delete Duplicate Folders in System||60.5%|Hard||
2089+
|1948|Delete Duplicate Folders in System||60.4%|Hard||
20902090
|1949|Strong Friendship||59.3%|Medium||
20912091
|1950|Maximum of Minimum Values in All Subarrays||50.9%|Medium||
20922092
|1951|All the Pairs With the Maximum Number of Common Followers||74.1%|Medium||

website/content/ChapterFour/0001~0099/0057.Insert-Interval.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,5 @@ func insert(intervals []Interval, newInterval Interval) []Interval {
7878
----------------------------------------------
7979
<div style="display: flex;justify-content: space-between;align-items: center;">
8080
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0001~0099/0056.Merge-Intervals/">⬅️上一页</a></p>
81-
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0001~0099/0059.Spiral-Matrix-II/">下一页➡️</a></p>
81+
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0001~0099/0058.Length-of-Last-Word/">下一页➡️</a></p>
8282
</div>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# [58. Length of Last Word](https://leetcode-cn.com/problems/length-of-last-word/)
2+
3+
## 题目
4+
5+
Given a string s consisting of some words separated by some number of spaces, return the length of the last word in the string.
6+
7+
A word is a maximal substring consisting of non-space characters only.
8+
9+
Example 1:
10+
11+
```
12+
Input: s = "Hello World"
13+
Output: 5
14+
Explanation: The last word is "World" with length 5.
15+
```
16+
17+
Example 2:
18+
19+
```
20+
Input: s = " fly me to the moon "
21+
Output: 4
22+
Explanation: The last word is "moon" with length 4.
23+
```
24+
25+
Example 3:
26+
27+
```
28+
Input: s = "luffy is still joyboy"
29+
Output: 6
30+
Explanation: The last word is "joyboy" with length 6.
31+
```
32+
33+
## 题目大意
34+
35+
给你一个字符串 s,由若干单词组成,单词前后用一些空格字符隔开。返回字符串中最后一个单词的长度。
36+
37+
单词 是指仅由字母组成、不包含任何空格字符的最大子字符串。
38+
39+
## 解题思路
40+
41+
- 先从后过滤掉空格找到单词尾部,再从尾部向前遍历,找到单词头部,最后两者相减,即为单词的长度
42+
43+
44+
----------------------------------------------
45+
<div style="display: flex;justify-content: space-between;align-items: center;">
46+
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0001~0099/0057.Insert-Interval/">⬅️上一页</a></p>
47+
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0001~0099/0059.Spiral-Matrix-II/">下一页➡️</a></p>
48+
</div>

website/content/ChapterFour/0001~0099/0059.Spiral-Matrix-II.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,6 @@ func generateMatrix(n int) [][]int {
9696

9797
----------------------------------------------
9898
<div style="display: flex;justify-content: space-between;align-items: center;">
99-
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0001~0099/0057.Insert-Interval/">⬅️上一页</a></p>
99+
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0001~0099/0058.Length-of-Last-Word/">⬅️上一页</a></p>
100100
<p><a href="https://books.halfrost.com/leetcode/ChapterFour/0001~0099/0060.Permutation-Sequence/">下一页➡️</a></p>
101101
</div>

website/content/ChapterTwo/String.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ weight: 2
2323
|0032|Longest Valid Parentheses|[Go]({{< relref "/ChapterFour/0001~0099/0032.Longest-Valid-Parentheses.md" >}})|Hard||||30.5%|
2424
|0043|Multiply Strings|[Go]({{< relref "/ChapterFour/0001~0099/0043.Multiply-Strings.md" >}})|Medium||||35.9%|
2525
|0049|Group Anagrams|[Go]({{< relref "/ChapterFour/0001~0099/0049.Group-Anagrams.md" >}})|Medium| O(n log n)| O(n)||61.8%|
26+
|0058|Length of Last Word|[Go]({{< relref "/ChapterFour/0001~0099/0058.Length-of-Last-Word.md" >}})|Easy||||34.4%|
2627
|0065|Valid Number|[Go]({{< relref "/ChapterFour/0001~0099/0065.Valid-Number.md" >}})|Hard||||17.0%|
2728
|0067|Add Binary|[Go]({{< relref "/ChapterFour/0001~0099/0067.Add-Binary.md" >}})|Easy||||48.5%|
2829
|0071|Simplify Path|[Go]({{< relref "/ChapterFour/0001~0099/0071.Simplify-Path.md" >}})|Medium| O(n)| O(n)||35.9%|

0 commit comments

Comments
 (0)