Given vector Z and an index vector I (which may contain repeats), add 1 to Z at each index in I for every time that index occurs (so an index repeated 3 times adds 3). Return the result.
Z
I
solve(...)