Problem

Return the index of target in arr, or -1 if it is not found.

Examples

  • linearSearch([4, 2, 7, 1], 7) -> 2
  • linearSearch([1, 2, 3], 5) -> -1
Compile and test (Ctrl+Enter)