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

Автор werewolf97, история, 6 лет назад, По-английски

Given a string A. You need to solve Q queries. In each queries, you will be given a string B[i]. You need to find the count of the number of substrings of A which are anagrams of B[i].

Contraints:

1<=|A|, |B[i]|<=10^5 1<=Q<=10^5 summation|B[i]|<=2x10^5 All the strings consists of lowercase English letters.

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

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

Provide a link to the statement or say where is this problem from, if you don't do this, i can't know if this problem is from a ongoing contest or not.

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

There are 1000 different values of len(B[i]) in Q queries. For each different value of len(B[i]), Iterate through A and store in map the cnt 26 length array of freq cnt for the length of substring. This takes O(1000*len(A)) and final ans can be done in O(1) per query.