Блог пользователя daihan

Автор daihan, 7 лет назад, По-английски

Given N strings , Then there will be q queries . In each query a string S , you have to determine in how many string ( N given string ) S is a subsequence of that string . For example

N=5

aeh

apoq

xyzq

alpqh

caqwerh

Q=1

ah

ans=3 , because "ah" is a subsequence of aeh , alpqh and caqwerh .

How to solve this problem effeciently . Suppose N=10^5 and Q=3*10^5 , Each string lenght would be <=10^2

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Any constraints on the size of the input strings?

»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

The following is a trie-based C++14 solution for the problem. 1. You can read about retrieval data structure (trie) in GeeksforGeeks.