AgreeYa Solutions' delivery dashboard stores record identifiers in ascending order. Given a sorted list of integers and a target identifier, implement binary search to return the target's index, or -1 if it is absent.
Your algorithm must repeatedly compare the target with the middle element and discard the half that cannot contain the target.
Implement binary_search(nums, target).
nums, a list of integers sorted in nondecreasing order, and target, an integer.target, or -1 when the target is not present.target is accepted.def binary_search(nums, target):