Your question is Binary Search Insert Position. 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.
Given a sorted array of distinct integers nums and an integer target, return the index if target is found. If it is not found, return the index where it should be inserted to keep the array sorted. Implement the solution in O(log n) time.
def search_insert(nums, target):