X1272: Linear Search Return Index

Complete the following linear search method. Find the number search in the array numbers. If the number is found, return the index for the position. If the number is not found, return -1. It is unspecified if the array is ordered or not, so assume it is not.

Examples:

linearSearch({1,7,4},7) -> 1
linearSearch({1,7,4},5) -> -1

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.