
insert 덮어쓰기prefix가 붙은 경우 합산 및 반환class MapSum {
private map: Map<string, number>
constructor() {
this.map = new Map<string, number>()
}
insert(key: string, val: number): void {
this.map.set(key, val)
}
sum(prefix: string): number {
let total = 0
for(const [key, val] of this.map) {
if(!key.startsWith(prefix)) continue
total += val
}
return total
}
}