Binary Search Position

Given a sorted array and a target, return the index (0-based) if found, else -1.

Input Format

Integer n
n space-separated integers
Target integer
er

Output Format

Index or -1

Sample Input

5
1 2 3 4 5
3

Sample Output

2

Try Your Code

← Back to Problems List