✕
Divide and ConquerCoding problems
Divide and Conquer: coding problems
Write a program that reads the input and prints the answer. Run checks it against every test, including hidden ones.
0 of 7 solved
A library keeps its book numbers in one long sorted list. A clerk must find a number without reading the whole list. Print the position of the number, counting from 0. Print -1 if the number is not on the list.
All numbers in the list are different.
Constraints: 1 to 800 numbers. Each number is between -1000000000 and 1000000000.
Input. First line: n. Second line: n numbers in increasing order. Third line: the number to find.
Output. One integer: the position (from 0), or -1.
Example 1 input
7 2 5 8 12 16 23 38 23
Output
5
Example 2 input
7 2 5 8 12 16 23 38 7
Output
-1