#C6713. Index Queries
Index Queries
Index Queries
Given an array of integers and a list of queries, each query is an integer. For each query, output the index of the first occurrence of that integer in the array. If the integer does not appear in the array, output \(-1\). The index is 0-based.
For example, if the array is [4, 2, 1, 5, 2, 3, 1] and the queries are [2, 5, 7], then the output should be [1, 3, -1].
inputFormat
The first line contains two integers: n and m, where n is the number of elements in the array and m is the number of queries.
The second line contains n space-separated integers representing the array.
The third line contains m space-separated integers representing the queries.
outputFormat
Output a single line containing m space-separated integers. Each integer represents the index (0-based) of the first occurrence of the corresponding query in the array, or -1
if the query value is not present.
7 3
4 2 1 5 2 3 1
2 5 1
1 3 2