MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / helper

Method helper

Python/word-break-1.py:12–23  ·  view source on GitHub ↗
(s,dict,dp)

Source from the content-addressed store, hash-verified

10 dict=set(wordDict)
11 dp = {}
12 def helper(s,dict,dp):
13 if s in dp:
14 return dp[s]
15 l=len(s)
16 if l==0:
17 return True
18 for i in range(l):
19 if s[:i+1] in dict and helper(s[i+1:],dict,dp):
20 dp[s[:i+1]] = True
21 return True
22 dp[s] = False
23 return False
24 return helper(s,dict,dp)
25
26

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected