You are given a string s and a list of strings wordDict representing a dictionary.
Your task is to determine whether s can be segmented into a space-separated sequence of one or more valid words from the dictionary.
The same word in the dictionary may be used multiple times in the segmentation.
Return true if the string can be segmented, otherwise return false.
Input: s = "programminghero" wordDict = ["program", "ming", "hero"]
Output: true
Input: s = "learnpythonfast" wordDict = ["learn", "python", "fast", "code"]
Output: true
Input: s = "helloleetcode" wordDict = ["hello", "leet", "code"]
Output: false
Accepted:
Submission: