Dsa
Trie
Easy
API Access Counter
You are monitoring API usage. Every log entry contains an endpoint (e.g., 'user.v1.login') and a hit count. You need to answer queries about the TOTAL hits for all endpoints sharing a specific prefix. For example, a query for 'user' should sum hits for 'user.v1.login' and 'user.v2.logout'.
Example:
Input:
3
user.login 5
user.logout 3
api.call 10
2
user
api
Output:
8
10
Key concepts
trieprefix-sumaggregation
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now