Index of First Occurrence Problem
Index of First Occurrence Problem — ExecCode School DSA Practice
Solve the Index of First Occurrence problem on ExecCode. Free online school DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Given an array of integers and a target integer, find the index of the first occurrence of the target. Your task is to solve Index of First Occurrence. If the target is not found, return -1.
Examples
Input 1 5 5; Output 0. Input 3 1 2 3 2; Output 1
Constraints
1 <= N <= 1000 -10^9 <= Array elements, K <= 10^9
Practice Index of First Occurrence free on ExecCode. Browse DSA problems, topic map, and placement guides.