Problem 2295 · Medium

Replace Elements in an Array

Keep a hash map from each value to its position, so each replacement finds its slot in constant time.

Open the interactive visualisation