You are given a string `s` and a dictionary of distinct words `dictionary`. Break `s` into one or more non-overlapping substrings so that each substring is a word in `dictionary`. Some characters of `s` may not belong to any chosen substring; they are extra. Return the minimum number of extra characters when you break `s` up optimally.
You are given a string s and a dictionary of distinct words dictionary. Break s into one or more non-overlapping substrings so that each substring is a word in dictionary. Some characters of s may not belong to any chosen substring; they are extra. Return the minimum number of extra characters when you break s up optimally.