13: Map Finger Exercises

Submit this homework using Gradescope. You can type up your answers, or write legibly and scan them. Do not attempt to submit a paper copy in class, as it will not be accepted.


A. (1 point) Suppose you want to store a map between Strings and sets of lists of chars, where each list of chars is a permutation of the characters of the String. What would the full, legal Java type of this map be?

B. (1 point) Suppose you had a Map<Integer, List<Integer>>. Write a method that returns the sum of all integers stored in all keys (not values) of the map, or zero if there are no keys.

C. (1 point) Suppose you had a Map<Integer, List<Integer>>. Write a method that returns the sum of all integers stored in all values (not keys) of the map (or within the collection(s) stored in the values), or zero if there are no such values.

D. (2 points) Suppose you had a Map<String, List<List<Integer>>>. Write a method that returns the sum of all integers stored in all values (or within the collection(s) stored in the values) of the map corresponding to keys that start with "a", or zero if there are no such values.