Find Element Index
Given an integer array
arr and an integer target. Write a function int IndexOf(int[] arr, int target) that returns the index of the first occurrence of target in the array, or -1 if the number is not found.Example 1
Input: arr = [1, 2, 3], target = 4
Output: -1
Explanation: The number 4 was not found in the array
Output: -1
Explanation: The number 4 was not found in the array
Example 2
Input: arr = [1, 2, 3, 2], target = 2
Output: 1
Explanation: The number 2 first appears in the array at index 1
Output: 1
Explanation: The number 2 first appears in the array at index 1
Example 3
Input: arr = [5], target = 5
Output: 0
Explanation: In a single-element array, the number 5 is at index 0
Output: 0
Explanation: In a single-element array, the number 5 is at index 0
Line 1, Char 1