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