Extra Characters in a String

Implement solve(arg1), where arg1 is a string array whose first element is the target string s and whose remaining elements are dictionary words. Return the minimum number of characters left over when s is broken into contiguous substrings that appear in the dictionary. Characters that cannot be matched by any dictionary word in the chosen segmentation count as extra.

If arg1 is empty, return 0. If arg1 contains only s and no dictionary words, every character of s is extra.

Examples
Input: ["abc","a","b","c"]
Output: 0
Hints

Extra Characters in a String

Implement `solve(arg1)`, where `arg1` is a string array whose first element is the target string `s` and whose remaining elements are dictionary words. Return the minimum number of characters left over when `s` is broken into contiguous substrings that appear in the dictionary. Characters that cannot be matched by any dictionary word in the chosen segmentation count as extra.