https://leetcode.com/problems/map-sum-pairs


Runtime: 112 ms, faster than 8.11% of TypeScript online submissions for Map Sum Pairs.
Memory Usage: 40.6 MB, less than 56.76% of TypeScript online submissions for Map Sum Pairs.


```typescript
class MapSum {
    theMap: Map<string, number>;
    
    constructor() {
        //7:02
        this.theMap = new Map();
        //7:09
    }

    insert(key: string, val: number): void {
        this.theMap.set(key, val)
    }

    sum(prefix: string): number {
        let result = 0
        for (const [key, value] of this.theMap) {
            if (key.length >= prefix.length) {
                if (key.substring(0, prefix.length) == prefix) {
                    result += value
                }
            }
        }
        return result
    }
}
```
