3093. Longest Common Suffix Queries
You are given two arrays of strings
wordsContainer
andwordsQuery
.For each
wordsQuery[i]
, you need to find a string fromwordsContainer
that has the longest common suffix withwordsQuery[i]
. If there are two or more strings inwordsContainer
that share the longest common suffix, find the string that is the smallest in length. If there are two or more such strings that have the same smallest length, find the one that occurred earlier inwordsContainer
.Return an array of integers
ans
, whereans[i]
is the index of the string inwordsContainer
that has the longest common suffix withwordsQuery[i]
.
c++
1 |
|