2490. Circular Sentence
Problem
Approach
Split each word, then concatenate the sentence with itself (e.g., "abc" → "abcabc"). Check whether the last character of each word equals the first character of the next word (wrapping around).
Code
class Solution:
def isCircularSentence(self, sentence: str) -> bool:
sentence = sentence.split(' ')
length = len(sentence)
sentence += sentence
for i in range(0, length):
if sentence[i][-1] != sentence[i+1][0]:
return False
return True贡献者
这篇文章有帮助吗?
最近更新
Involution Hell© 2026 byCommunityunderCC BY-NC-SA 4.0
2341. Maximum Number of Pairs in Array — Daily Problem
LeetCode 2341. Maximum Number of Pairs in Array — Hash table or sorting approach to count pairs and leftovers, for developers practicing array frequency problems.
2562. Find the Array Concatenation Value
LeetCode 2562. Find the Array Concatenation Value — two-pointer approach to concatenate first and last numbers as strings and sum them, for intermediate Python learners.