#C12040. Find Book Positions
Find Book Positions
Find Book Positions
You are given a list of book titles and a list of query strings. For each query, determine the 1-indexed position of the book in the list if it exists. The search is case-sensitive, meaning that the title must match exactly. If the book is not found, output "Not found" for that query.
In mathematical terms, if we denote the array of book titles as \(B = [b_1, b_2, \dots, b_n]\) and the array of queries as \(Q = [q_1, q_2, \dots, q_m]\), then for each query \(q_j\), output the index \(i\) (where \(1 \leq i \leq n\)) such that \(b_i = q_j\), or output "Not found" if no such \(i\) exists.
inputFormat
The input is read from stdin
and is formatted as follows:
- An integer \(n\) representing the number of book titles.
- \(n\) lines follow, each containing a book title.
- An integer \(q\) representing the number of queries.
- \(q\) lines follow, each containing a query string.
outputFormat
For each of the \(q\) queries, output the corresponding 1-indexed position of the book if found, otherwise output Not found
. Each answer should be printed on a new line to stdout
.
5
The Great Gatsby
1984
To Kill a Mockingbird
The Catcher in the Rye
Pride and Prejudice
3
1984
To Kill a Mockingbird
Pride and Prejudice
2
3
5
</p>