pyassistant

Minimum Word Concatenation Count (Word Break Min Count)

Given a target string s and a list of words (a dictionary), determine the minimum number of words from the list that need to be concatenated (words may be reused any number of times) to form s exactly. If it's impossible to form s using the given words, return -1. Notes: - The concatenation must produce s exactly, with no extra characters. - Each word from the list can be used multiple times. - Return 0 if s is empty (empty concatenation). Example: Input: s = "leetcode", words = ["leet", "code"] Output: 2

Example:

Input:
("leetcode", ["leet", "code"])
Output:
2

Make sure you return your solution, don't print!

AI

Bot

Trying to solve my challenge? Ask if you must, or press the purple button so I can analyze your code.