package q139 func wordBreak(s string, wordDict []string) bool { possible := make([]bool, len(s)+1) possible[0] = true for l := range possible { if !possible[l] { continue } for i := range wordDict { newLen := len(wordDict[i]) + l if newLen > len(s) { continue } if possible[newLen] { continue } if s[l:newLen] == wordDict[i] { possible[newLen] = true } } } return possible[len(s)] } var _ = wordBreak