shlogg · Early preview
Md Ariful Haque @mah-shamim

Extra Characters In String: Min Extra Char Left Over

Break string s into non-overlapping substrings from dictionary. Min extra chars = dp[len(s)]. DP[i] = min(dp[i-1]+1, min(dp[j]) if s[j:i] in dict).

2707. Extra Characters in a String
Difficulty: Medium
Topics: Array, Hash Table, String, Dynamic Programming, Trie
You are given a 0-indexed string s and a dictionary of words dictionary. You have to break s into one or more non-overlapping substrings such that each substring is present in dictionary. There may be some extra characters in s which are not present in any of the substrings.
Return the minimum number of extra characters left over if you break up s optimally.
Example 1:

Input: s = "leetscode", dictionary = ["leet","code","leetcode"]
Output: 1
Explanation: We can break s in two sub...