Given a string str and a list of words dict, determine if str can be segmented into a sequence of one or more words from dict. Words from dict can be reused multiple times in the segmentation.
Return true if it is possible to segment str, and false otherwise.
str: string: A string representing the string to be segmenteddict: string[]: An array of strings representing the dictionary of available wordsdict can be used multiple times in the segmentationInput: str = "greatfrontendgreat", dict = ["frontend","great"]Output: trueExplanation: The string can be segmented as 'great' + 'frontend' + 'great' as we can re-use 'great'.
Input: str = "abcd", dict = ["a","abc","b","cd"]Output: trueExplanation: The string can be segmented as 'a' + 'b' + 'cd'.
Input: str = "a", dict = ["b"]Output: falseExplanation: The single character 'a' is not in the word dictionary.
str.length <= 300dict.length <= 300dict[i].length <= 300str and dict[i] consist of only lowercase English lettersconsole.log() aparecerão aqui.