Quant Memo
Coding/●●●●●

Keep the latest version of each amended fill

Your fills feed sends an event (fill_id, payload) whenever a fill is booked, and re-sends the same fill_id with an updated payload each time the fill is amended (price correction, quantity change). Downstream you want the final version of every fill, and you want them ordered by where each fill's last amendment appeared.

events = [(1,"a"), (2,"b"), (1,"c"), (3,"d"), (2,"e")]
-> [(1,"c"), (3,"d"), (2,"e")]

Return one entry per id carrying its last payload, ordered by the position of that last occurrence. Aim for O(1)O(1) per event.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions