Minimize deletions to form concatenation of dictionary words
Given a string s and a list of words, compute the minimal number of deletions needed so the remaining (possibly non-contiguous) characters form a non-empty concatenation of words from the list. Return -1 if impossible.
Example:
Input:
('abxcab', ['ab', 'cab'])
Output:
1
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.