Put several pairs
Updated
A sequence of puts is last-write-wins per key. Distinct keys accumulate. Repeating a key in the sequence is an overwrite, not a second entry.
What to focus on
Puts 4→2, 1→8, 9→3, 1→0 leave {4:2, 1:0, 9:3}. Order of first-seen keys is not an iteration contract.
Worked examples
three distinct
a = [], put 4→2, 1→8, 9→3- size grows 0,1,2,3
Result: {4:2, 1:8, 9:3}
with overwrite
a = [], put 4→2, 1→8, 4→0- 4 ends at 0
- size 2
Result: {4:0, 1:8}
all same key
a = [], put 4→1, 4→2, 4→3- one key
- last value 3
Result: {4:3} · size 1
Try it
Write putMany(m, pairs). m starts as {}. pairs is the list of (k, v) to put in order. Last write wins per key. Print the map after the sequence. a = [], put 4→2, 1→8, 9→3 → {4:2, 1:8, 9:3}. a = [], put 4→2, 1→8, 4→0 → {4:0, 1:8}. a = [], put 4→1, 4→2, 4→3 → {4:3} · size 1.
keys and values are integers. Start from {} and apply the listed puts in order.