Implement a binary search algorithm that finds the index of a target value in a sorted array. If the target value is not found, return -1.
nums.target to search for.target in nums or -1 if target is not present.def binary_search(nums: list[int], target: int) -> int: