3302. Find the Lexicographically Smallest Valid Sequence
You are given two strings
word1
andword2
.A string
x
is called almost equal toy
if you can change at most one character inx
to make it identical toy
.A sequence of indices
seq
is called valid if:
- The indices are sorted in ascending order.
- Concatenating the characters at these indices in
word1
in the same order results in a string that is almost equal toword2
.Return an array of size
word2.length
representing 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 { |