#B2093. Find the First Occurrence in a Sequence
Find the First Occurrence in a Sequence
Find the First Occurrence in a Sequence
Given a sequence with indices starting from \(0\), you are required to find the first occurrence of a given target value in the sequence and output its index.
inputFormat
The input consists of three lines:
- The first line contains an integer \(n\) representing the number of elements in the sequence.
- The second line contains \(n\) integers separated by spaces.
- The third line contains an integer representing the target value to search for.
outputFormat
Output the index (0-indexed) of the first occurrence of the target value in the sequence.
sample
5
1 2 3 2 1
2
1