Problem 1409 · Medium

Queries on a Permutation With Key

Answer queries by finding each queried value's position in a list, then moving that value to the front. The visual shows the list reordering after each query.

Open the interactive visualisation