Invert a Map
Create a method named invert
.
invert
should accept a Map<String, Int>
and return a Map<Int, String>
with all of the key-value
pairs swapped.
Because values are not necessarily unique in a map, normally you would need a way to determine what the right approach is when two keys map to the same value. However, the maps passed to your function will not have any duplicate values.