Your question is Binary Search and Complexity. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
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):