討論串[閒聊] 每日leetcode
共 1554 篇文章
內容預覽:
我一開始看也想說. 阿就字典樹隨便丟. 後來看一下easy. 喔應該掃一遍就沒了ㄅ. class Solution {. public:. int isPrefixOfWord(string s, string w) {. int n = s.length(), m = w.length();. i
(還有1160個字)
內容預覽:
想說要用trie什麼之類的. 看到綠色的標題. 我就懶了. 我好爛. def isPrefixOfWord(self, sentence: str, searchWord: str) -> int:. for i, w in enumerate(sentence.split(' ')):. if w
(還有17個字)
內容預覽:
2097. Valid Arrangement of Pairs. 思路:. 用有向圖去解. 先找start的那個點. 如果有一個點的indegree-outdegree是-1,那他就是start. 注意不一定會有這樣的點. 如果每個點的outdegree-indegree都是0,那就隨便找個點當s
(還有1016個字)