Minimum cost word segmentation
Your task
Given a lowercase string s and a dictionary of (word, cost) pairs, segment s into a sequence of dictionary words minimizing the total cost (each used word contributes its cost; a word may be used multiple times). Return the minimum total cost, or -1 if s cannot be segmented. Words can repeat in the input only once each. Length of s up to ~1000.
Examples
min_cost_word_break(s: str, words: list[list]) -> intExample 1
Input
min_cost_word_break("notebook", [["note", 3], ["book", 4], ["notebook", 10]])Output
7