find first occurance of a number in a sorted array increasing order approach binary search tn olog n returns the index of the first occurance of the given element in an array the array has to be sorted in increasing order printlo lo hi hi mid mid returns the index of the first occurance of the given element in an array the array has to be sorted in increasing order now mid will be ininteger range print lo lo hi hi mid mid
def first_occurrence(array, query):
    

    low, high = 0, len(array) - 1
    while low <= high:
        mid = low + (high-low)//2 
        
        if low == high:
            break
        if array[mid] < query:
            low = mid + 1
        else:
            high = mid
    if array[low] == query:
        return low