代码拉取完成,页面将自动刷新
<p>A <strong>sentence</strong> is a list of words that are separated by a<strong> single</strong> space with no leading or trailing spaces.</p>
<ul>
<li>For example, <code>"Hello World"</code>, <code>"HELLO"</code>, <code>"hello world hello world"</code> are all sentences.</li>
</ul>
<p>Words consist of <strong>only</strong> uppercase and lowercase English letters. Uppercase and lowercase English letters are considered different.</p>
<p>A sentence is <strong>circular </strong>if:</p>
<ul>
<li>The last character of a word is equal to the first character of the next word.</li>
<li>The last character of the last word is equal to the first character of the first word.</li>
</ul>
<p>For example, <code>"leetcode exercises sound delightful"</code>, <code>"eetcode"</code>, <code>"leetcode eats soul" </code>are all circular sentences. However, <code>"Leetcode is cool"</code>, <code>"happy Leetcode"</code>, <code>"Leetcode"</code> and <code>"I like Leetcode"</code> are <strong>not</strong> circular sentences.</p>
<p>Given a string <code>sentence</code>, return <code>true</code><em> if it is circular</em>. Otherwise, return <code>false</code>.</p>
<p> </p>
<p><strong class="example">Example 1:</strong></p>
<pre>
<strong>Input:</strong> sentence = "leetcode exercises sound delightful"
<strong>Output:</strong> true
<strong>Explanation:</strong> The words in sentence are ["leetcode", "exercises", "sound", "delightful"].
- leetcod<u>e</u>'s last character is equal to <u>e</u>xercises's first character.
- exercise<u>s</u>'s last character is equal to <u>s</u>ound's first character.
- soun<u>d</u>'s last character is equal to <u>d</u>elightful's first character.
- delightfu<u>l</u>'s last character is equal to <u>l</u>eetcode's first character.
The sentence is circular.</pre>
<p><strong class="example">Example 2:</strong></p>
<pre>
<strong>Input:</strong> sentence = "eetcode"
<strong>Output:</strong> true
<strong>Explanation:</strong> The words in sentence are ["eetcode"].
- eetcod<u>e</u>'s last character is equal to <u>e</u>etcode's first character.
The sentence is circular.</pre>
<p><strong class="example">Example 3:</strong></p>
<pre>
<strong>Input:</strong> sentence = "Leetcode is cool"
<strong>Output:</strong> false
<strong>Explanation:</strong> The words in sentence are ["Leetcode", "is", "cool"].
- Leetcod<u>e</u>'s last character is <strong>not</strong> equal to <u>i</u>s's first character.
The sentence is <strong>not</strong> circular.</pre>
<p> </p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= sentence.length <= 500</code></li>
<li><code>sentence</code> consist of only lowercase and uppercase English letters and spaces.</li>
<li>The words in <code>sentence</code> are separated by a single space.</li>
<li>There are no leading or trailing spaces.</li>
</ul>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。