Implement a binary search algorithm that takes a sorted array and a target value, and returns the index of the target if found, or -1 if not found.
Implement a binary search algorithm that takes a sorted array and a target value, and returns the index of the target if found, or -1 if not found.
Example
Input: [1,3,5,7,9], 5
Output: 2