Skip to content
C

Binary Search

Easyjavapythonccppjavascript

Given a sorted array of distinct integers and a target value, find the target using binary search.

Input Format

The first line contains two integers N and target. The second line contains N space-separated integers in strictly increasing order.

Output Format

Print the index of target, or -1 if it is not present.

Input (stdin)

Output

Run your code to see output here...