Skip to main content

Practice ยท 2 of 2

Index a List with Map

Write indexById(users) that returns a Map from each user's id to the user object, and lookup(index, id) that returns the user or null when absent. Then write groupByRole(users) returning a Map from role to an array of users with that role.

Difficulty: intermediate

Back to lesson: Practice: Choosing Structures โ€” Practice