You are given two strings, word1 and word2.
A sequence of indices seq is considered valid if:
The length of seq is equal to the length of word2.
The indices are strictly increasing, satisfying seq[0] seq[1] seq[word2.length word1.length.
The string formed by concatenating word1[seq[0]], word1[seq[1]], …, word1[seq[word2.length word2.
Two strings
Return an array representing the lexicographically smallest valid sequence of indices. If no valid sequence exists, return an empty array.
Note: An array
ais lexicographically smaller than an arraybif at the first index where they differ, the element inais strictly less than the element inb.
Constraints:
word2.length word1.length
word1 and word2 consist only of lowercase English letters.
You are given two strings, word1 and word2.
A sequence of indices seq is considered valid if:
The length of seq is equal to the length of word2.
The indices are strictly increasing, satisfying seq[0] seq[1] seq[word2.length word1.length.
The string formed by concatenating word1[seq[0]], word1[seq[1]], …, word1[seq[word2.length word2.
Two strings
Return an array representing the lexicographically smallest valid sequence of indices. If no valid sequence exists, return an empty array.
Note: An array
ais lexicographically smaller than an arraybif at the first index where they differ, the element inais strictly less than the element inb.
Constraints:
word2.length word1.length
word1 and word2 consist only of lowercase English letters.