beyondgrader.com Logo
DemoBrowseAboutTeamLogin

Invert a Map

Geoffrey Challen // 2020.10.0

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.