Map Sum Pairs
A medium-tier problem at 57% community acceptance, tagged with Hash Table, String, Design. Reported in interviews at Akuna Capital and 0 others.
Map Sum Pairs is the design problem that trips up candidates who skip the data structure section. It sits at medium difficulty with a 57% acceptance rate, which means half the people walking in cold fail it. Akuna Capital asks it. The problem looks simple: implement a map that supports insert and sum operations on key-value pairs where keys are strings and you need to return the sum of all values with keys that share a given prefix. Most candidates jump to a HashMap and iteration, then realize prefix matching kills their approach. If this lands in your OA and you don't have the pattern locked, StealthCoder surfaces the working solution invisible to the proctor.
Companies that ask "Map Sum Pairs"
Map Sum Pairs is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know.
Get StealthCoderThe trick here is recognizing that a naive HashMap won't efficiently handle prefix queries. You need a Trie structure that stores values at each node. When you insert a key-value pair, you traverse or build the Trie path for that key and update the sum at each node along the way. When you query with a prefix, you traverse to the end of that prefix and return the sum stored there. It works because the Trie accumulates all sums for all keys that pass through that node. The pitfall: candidates implement insert correctly but mess up the sum tracking when overwriting an existing key. The trick is storing the old value, subtracting it from all ancestor nodes, then adding the new value. This is a pure design problem, not heavy algorithmic analysis, so execution and clarity matter. Hash Table and String topics are decoys. Trie and Design are where the real pattern lives.
Pattern tags
You know the problem.
Make sure you actually pass it.
Map Sum Pairs recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Map Sum Pairs interview FAQ
Is Map Sum Pairs a hard design problem or just tedious?+
It's medium and cleaner than it looks. The heavy lift is building and navigating the Trie structure correctly. Once you see that each node stores a running sum, the logic is straightforward. Most failures come from edge cases around updating existing keys, not the core structure.
Do I really need a Trie for this or can I use a HashMap?+
A pure HashMap forces you to iterate all keys on every sum query to check prefixes. That's O(n) per query. A Trie does it in O(m) where m is the prefix length. Trie is the intended solution and what Akuna expects. Interviewers ask this specifically to test if you know when to reach for a Trie.
What's the tricky part about updating a key's value in the Trie?+
When you insert a key that already exists with a different value, you can't just update the leaf. You have to subtract the old value from every ancestor node, then add the new value back through the same path. Missing this causes all prefix sums downstream to be wrong.
How do the topics relate: Hash Table, String, Design, Trie?+
Hash Table is a distractor. String tells you keys are strings, so you're building a Trie of characters. Design is the real category: you're architecting a data structure, not solving an algorithm. Trie is the core pattern. The problem is testing design choice under prefix-query constraints.
What if the OA blocks Trie implementation and forces a HashMap?+
Unlikely given the problem statement, but if constrained to HashMap only, implement it naively: store all pairs, iterate on sum queries to match prefixes. It'll pass small tests and fail at scale. That said, the problem is designed to require Trie. Akuna wouldn't ask it otherwise.
Want the actual problem statement? View "Map Sum Pairs" on LeetCode →