Your question is Binary Search From Scratch. 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.
The Medbridge exercise library stores exercise IDs in a sorted list so clinicians can locate content efficiently. Implement binary search from scratch to return the index of the first occurrence of a target ID.
The input list is sorted in nondecreasing order and may contain duplicate values. If the target does not exist, return -1.
Implement binary_search(nums, target):
nums, a list of integers sorted in nondecreasing order, and target, an integer.target, or -1 if no matching element exists.O(1) auxiliary space.def binary_search(nums, target):