Given a sorted array of integers and a target value, return the index of the target element if it is present in the array. If the target is not found, return -1. The array is sorted in non-decreasing order, and the search should be performed efficiently using binary search.
Input: arr = [1,3,5,7,9], target = 7
Output: 3
Explanation: The target value 7 is present at index 3 in the array.
Input: arr = [2,4,6,8,10], target = 5
Output: -1
Explanation: The target value 5 is not present in the array, so return -1.
Input: arr = [11,22,33,44], target = 11
Output: 0
Explanation: The target value 11 is present at index 0 in the array.
Sign in to write, run, and submit your solution against the full test suite.