Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Create the permutation P=[1,2,...,m], it could be a list for example.
For each i, find the position of queries[i] with a simple scan over P and then move this to the beginning.