Given a string s and a dictionary of words, return the number of distinct ways s can be segmented into a sequence of dictionary words (words may be reused). Input: JSON {s, words}.
Input: JSON {s, words}.
Output: Integer — number of segmentations.
Input: {"s":"catsanddog","words":["cat","cats","and","sand","dog"]}
Output: 2
Explanation: 'cats and dog' and 'cat sand dog'.Input: {"s":"pineapplepenapple","words":["apple","pen","applepen","pine","pineapple"]}
Output: 3
Explanation: Three segmentations.Input: {"s":"catsandog","words":["cats","dog","sand","and","cat"]}
Output: 0
Explanation: No valid segmentation.1<=s.length<=1001<=words.length<=1000