Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words.
Note that the same word in the dictionary may be reused multiple times in the segmentation.
Recurrence Relation: dp[i] = true if there exists j < i such that dp[j] is true AND s[j..i-1] is in wordDict
dp[i] represents whether the substring s[0..i-1] can be segmented using dictionary words.
This problem combines string processing with dynamic programming and can also be solved with BFS or memoized recursion.
s = "leetcode", wordDict = ["leet","code"]trues = "applepenapple", wordDict = ["apple","pen"]trues = "catsandog", wordDict = ["cats","dog","sand","and","cat"]false1 <= s.length <= 3001 <= wordDict.length <= 10001 <= wordDict[i].length <= 20s and wordDict[i] consist of only lowercase English letters.All the strings of wordDict are unique.Click "Run" to execute your code against test cases
Socratic guidance - I'll ask questions, not give answers