139. 单词拆分
首先要明确这个是求排列数,所以是先遍历背包,再遍历物品。

func wordBreak(s string, wordDict []string) bool {
dp := make([]bool, len(s) + 1)
dp[0] = true
for j := 1; j <= len(s); j++{
for i := 0; i < len(wordDict); i++{
if j - len(wordDict[i]) >= 0 && dp[j - len(wordDict[i])] == true && wordDict[i] == s[(j - len(wordDict[i])) : j]{
dp[j] = true
}
}
}
return dp[len(s)]
}


![char *str 与char str[]的区别与联系](https://img-blog.csdnimg.cn/5dc9f4acddcb4d93a4a27985e5e11041.png)




![[牛客复盘] 牛客周赛 Round 9 20230827](https://img-blog.csdnimg.cn/c5c9be61c6534234bc0a2f7927927ee3.png)











