Yunyi is given a sentence consisting of lowercase Latin letters and spaces,
Yunyi will give you i j c
, which asks for the frequency of letter
) are not considered letters, and therefore will not be queried.
Input Specification
The first line will contain the sentence
The second line will contain the integer
The next
The sentence will only consist of lowercase Latin characters and spaces. There will only be one space between any 2 words, and there will be no leading/trailing spaces.
Output Specification
For each query, print the frequency of the letter
Constraints
Subtask 1 [10%]
Subtask 2 [90%]
No additional constraints.
Sample Input
this is a very interesting sentence and you will agree
4
1 4 h
6 6 p
15 26 t
1 54 e
Sample Output
1
0
2
8
Comments
ten thousand grams of pure caffeine aint cutting it 🧋🧋🧋
Since the original test data was weak, 7 new cases were added and all submissions rejudged.
Any strategy to speed the code up? I can only get 10 out of 100. Is a memory system the way to go?
Aim for constant time queries, right now you have linear queries in
.
You can do constant queries using prefix sum arrays.
thanks