(self, s: str, wordDict: List[str])
| 7 | |
| 8 | class Solution: |
| 9 | def wordBreak(self, s: str, wordDict: List[str]) -> bool: |
| 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 | |
| 27 | # Method 2 : Tabulation |
nothing calls this directly
no outgoing calls
no test coverage detected