#3302

Find the Lexicographically Smallest Valid Sequence

expert · 1190 · lc medium +32 · 21.6% accepted · 160 likes · top 2%

Description

You are given strings word1 and word2. String x is almost equal to y if at most one character in x can be changed to make them identical. A valid index sequence is sorted ascending and the characters of word1 at those positions (in order) form a string almost equal to word2.

Return the lexicographically smallest valid sequence of length word2.length, or an empty array if none exists.

Code

1
2
3