Re: [閒聊] 每日leetcode
想說要用trie什麼之類的
看到綠色的標題
我就懶了
我好爛
def isPrefixOfWord(self, sentence: str, searchWord: str) -> int:
for i, w in enumerate(sentence.split(' ')):
if w.startswith(searchWord):
return i+1
return -1
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.229.37.69 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1733149643.A.7B0.html
推
12/02 22:28,
1年前
, 1F
12/02 22:28, 1F
→
12/02 22:33,
1年前
, 2F
12/02 22:33, 2F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1172 之 1548 篇):