Maps and sets

Which value does get("a") return?

Examples

Worked example

Input
A map receives put("a", 1) and then put("a", 2).
Expected output
2

Hints and solution

Hint 1

Write down the starting state and walk through one example by hand.

Reveal worked answer

The second put replaces the previous value for that key.

Back to the lesson