Skip to content
C

First Occurrence in Sorted Array

Easyjavapythonccppjavascript

Given a sorted array that may contain duplicate values, find the first index at which a target value appears.

Input Format

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

Output Format

Print the first index of target, or -1 if it does not exist.

Input (stdin)

Output

Run your code to see output here...