Your question is Binary Search in Sorted Logs. 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.
At Google, security systems often search sorted event IDs or rule identifiers quickly. Write a function that uses binary search to find a target integer in a sorted array.
Return the index of target if it exists in the array. If it does not exist, return -1.
nums: a list of integers sorted in ascending ordertarget: an integer to search fortarget in nums, or -1 if not foundYour solution should run in O(log n) time.
def binary_search(nums, target):