another string query!!

Правка en1, от parag776, 2023-06-24 00:00:22

Suppose I have a list of strings S, each string at most 50 characters long. I'm looking for a data structure and algorithm that can handle the following query efficiently:

Given another list of strings G (a small list of at most 20 strings), I want to find the lexicographically smallest subset of at most 15 strings from S. The result should satisfy the condition that each string in G is a substring of each and every string in the result. i need fast query.

I've searched extensively but couldn't find a satisfactory answer. Most solutions I found address the case with a single string in G, but I need to handle multiple strings as stated above.

Example: S: ["hello my", "yuck ", "mr elan", "now is the", "parag", "hello", "my"] Query: G: ["el", "m"] Desired Result: ["hello my", "mr elan"]

If anyone has insights or knows the answer, please share your knowledge.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский parag776 2023-06-24 00:02:29 70
en1 Английский parag776 2023-06-24 00:00:22 904 Initial revision (published)