LeetCode 2490, Easy. Topics: String. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 30 parametrized pytest cases, and a playground notebook:
Problem
<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 each word in the sentence is equal to the first character of its 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>
Examples
Constraints
- 1 <= sentence.length <= 500
- sentence consist of only lowercase and uppercase English letters and spaces.
- The words in sentence are separated by a single space.
- There are no leading or trailing spaces.
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
NeetCode All. Last modified on September 7, 2026