Question bank › Binary Search
Dsa Binary Search Warm-up

Find First Occurrence

Given a sorted array of integers and a target value, return the index of the first occurrence of the target in the array. If the target is not present, return -1. Input Format: - The first line contains an integer n, the number of elements in the array. - The second line contains n space-separated integers. - The third line contains the target integer. Output Format: - Print the index of the first occurrence of the target value. Example: Input: 5 1 2 2 3 4 2 Output: 1

Key concepts

binary_searcharrayssearch

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.