Problem statement
Given an array and a target, return the first index whose value equals the target.
Return -1 if no value matches. The array does not need to be sorted.
Examples
Inputa = [6, 3, 8, 3, 9], target = 3
Output1
Index 1 is the first matching position.
Inputa = [4, 7, 1, 6], target = 2
Output-1
Every cell is checked and none matches.
The walkthrough is part of Premium
The statement and the examples above stay free. The full how-to-solve walkthrough, the cost notes in plain words and the interactive step-by-step visualizer unlock with a Premium plan.
See pricing