Trie Prefix Counter

Programming Interview Hard 5 views
Back to Questions

Problem Description

We have {x}. Create Trie class. For COUNT output how many added words have this prefix.

Input Format

First line q. Next q lines operations.

Output Format

Outputs for COUNT.

Sample Test Case

Input:
7 ADD apple ADD app COUNT ap COUNT app ADD apply COUNT app COUNT b
Output:
2 2 3 0

Constraints

q

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next