A string X is an ordered superstring of the String[] words if
- Each element of words is a substring of X.
- There exists a sequence of indices x_1 <= x_2 <= ... <= x_n, where n is the number of elements in words. For each element k of words, where k is a 1-based index, there is an occurrence of words[k] that starts at the x_k-th letter of X.
For example "abca" is an ordered superstring of {"abc", "ca"}, but "cabc" is not.
Given a String[] words, return the length of its shortest ordered superstring.
|