Find the 1-based position of a target marble after tracking swaps among a sequence of marbles.
You are given a collection of marbles initially placed in a known order. One marble is special: the query asks for the position of a particular marble after a sequence of updates/swaps is processed.
Your task is to determine where the queried marble ends up.
A typical solution keeps track of where each marble is located instead of simulating the entire arrangement from scratch after every operation.
Example 1
Input
5 1 2 3 4 5 query 3
Output
3
Explanation
The marble labeled 3 is already in position 3.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.