Answers for "index for inserting in sorted list"

0

index for inserting in sorted list

def find_index(arr, n, B):
     start = 0
    end = n - 1
     while start<= end:
        mid =(start + end)//2
        if arr[mid] == K:
            return mid
        elif arr[mid] < K:
            start = mid + 1
        else:
            end = mid-1
    return end + 1
Posted by: Guest on July-11-2021

Browse Popular Code Answers by Language