The Codetikki treasury maintains a map of keys with integer values. They need to quickly compute the sum of all values for keys that begin with a given prefix. Implement a PrefixMapSum class with: insert(key, value) - set key to value (overwrite if exists), and sum(prefix) - return the sum of all values of keys beginning with prefix.
Example 1:
Example 2:
Constraints:
1 <= number of operations <= 10^4 1 <= key length <= 100 -10^9 <= value <= 10^9
Tags:
