1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-12-11 21:30:58 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-03-29 12:43:11 +08:00
parent 58bbdfd57c
commit 2b0511d272
10721 changed files with 8123 additions and 8119 deletions

View File

@@ -0,0 +1,39 @@
<p>给你一个字符串 <code>s</code>,由若干单词组成,单词前后用一些空格字符隔开。返回字符串中 <strong>最后一个</strong> 单词的长度。</p>
<p><strong>单词</strong> 是指仅由字母组成、不包含任何空格字符的最大子字符串。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>s = "Hello World"
<strong>输出:</strong>5
<strong>解释:</strong>最后一个单词是“World”长度为5。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>s = " fly me to the moon "
<strong>输出:</strong>4<strong>
解释:</strong>最后一个单词是“moon”长度为4。
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>s = "luffy is still joyboy"
<strong>输出:</strong>6
<strong>解释:</strong>最后一个单词是长度为6的“joyboy”。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= s.length &lt;= 10<sup>4</sup></code></li>
<li><code>s</code> 仅有英文字母和空格 <code>' '</code> 组成</li>
<li><code>s</code> 中至少存在一个单词</li>
</ul>