Prefix Count Queries

Programming Interview Medium 4 views
Back to Questions

Problem Description

Consider {x}. For each word, count all its prefixes. Then q prefixes are provided. For each prefix output how many words start with it.

Input Format

First line n. Next n lines words. Next line q. Next q lines prefix.

Output Format

q lines counts.

Sample Test Case

Input:
3 apple app bat 4 ap app apple b
Output:
2 2 1 1

Constraints

Total characters

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next