Submit | All submissions | Best solutions | Back to list |
PES16SEQ - Search for an integer using sequential search |
Write a program to search for an element in an array of n elements using sequential search algorithm.
Input
Input begins with t (1 ≤ t ≤ 100) of number of test-cases in the first line and the test-cases are in the following lines. Each test-case begins with n (1 ≤ n ≤ 1,000,000) of number of integers (-231 ≤ integer ≤ 231 - 1) in the array in a single line and followed by n lines having an integer in each line and the integer to be searched in a new line.
Output
For each test-case, print the index (0 ≤ index ≤ n-1) of the first appearance of the search element in the array in a new line. Print ‘-1’ if the element is not found in the array.
Example
Input: 3 4 999999 0 -999999 1234 1234 4 999999 0 -999999 1234 -1234 4 999999 0 -999999 1234 999999 Output: 3 -1 0
Added by: | Prof. Channa Bankapur |
Date: | 2016-01-01 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | C |