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):