This commit is contained in:
parent
b06692b5f2
commit
ef558d6ee0
1 changed files with 14 additions and 0 deletions
14
easy/circular_sentence.py
Normal file
14
easy/circular_sentence.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# https://leetcode.com/problems/circular-sentence
|
||||
|
||||
class Solution:
|
||||
def isCircularSentence(self, sentence: str) -> bool:
|
||||
words = sentence.split(' ')
|
||||
last = words[0][len(words[0]) - 1]
|
||||
for word in words[1:]:
|
||||
if last != word[0]:
|
||||
return False
|
||||
last = word[len(word) - 1]
|
||||
|
||||
return last == words[0][0]
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue