3302. Find the Lexicographically Smallest Valid Sequence
You are given two strings
word1andword2.A string
xis called almost equal toyif you can change at most one character inxto make it identical toy.A sequence of indices
seqis called valid if:
- The indices are sorted in ascending order.
- Concatenating the characters at these indices in
word1in the same order results in a string that is almost equal toword2.Return an array of size
word2.lengthrepresenting the lexicographically smallest valid sequence of indices. If no such sequence of indices exists, return an empty array.Note that the answer must represent the lexicographically smallest array, not the corresponding string formed by those indices.
1 | class Solution { |