Given an array of positive integers queries and an integer m, consider a permutation P containing all integers from m initialized in increasing order.
For each query queries[i]:
Find the queries[i] in the permutation P.
Move queries[i] to the start of the permutation P.
Return an array containing the resulting positions for all processed queries.
Constraints:
m
queries.length m
queries[i] m
Given an array of positive integers queries and an integer m, consider a permutation P containing all integers from m initialized in increasing order.
For each query queries[i]:
Find the queries[i] in the permutation P.
Move queries[i] to the start of the permutation P.
Return an array containing the resulting positions for all processed queries.
Constraints:
m
queries.length m
queries[i] m