A pocket-money diary: kinds[i] is what entry i was spent on and amounts[i] is how much; both slices are the same length. Write SpendByKind(kinds, amounts) to return the total spent on each kind.
SpendByKind([]string{"snack", "bus", "snack"}, []int{5, 2, 3})→{'bus': 2, 'snack': 8}SpendByKind([]string{}, []int{})→{}func SpendByKind(kinds []string, amounts []int) map[string]intpackage main
func SpendByKind(kinds []string, amounts []int) map[string]int {
total := map[string]int{}
for i, k := range kinds {
// your code here: add entry i's amount to its kind
}
return total
}
Run tries the examples. When they look right, Submit.