Map Sum Pairs
easy
Implement the MapSum class: 1. MapSum() Initializes the MapSum object. 2. void insert(String key, int val) Inserts the key-val pair into the map. If the key already existed, the original key-value pair will be overridden to the new one. 3. int sum(string prefix) Returns the sum of all the pairs' value whose key starts with the prefix.
Constraints
1. 1 <= key.length, prefix.length <= 50 2. key and prefix consist of only lowercase English letters. 3. 1 <= val <= 1000
Format
Input
Input is managed for you
Output
Output is managed for you
Example
Sample Input
apple 3
ap
app 2
apple 2
ap
exit
Sample Output
3
4