summaryrefslogtreecommitdiff
path: root/progs/a397.py
blob: 34f81a59a537dd31984b50110ebe002ab497dd89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
def find_missing(ar,N): 
    l = 0
    r = N - 1
    while (l <= r):  
        mid = (l + r) / 2
        mid= int (mid) 
        if (ar[mid] != mid + 1 and ar[mid - 1] == mid): 
            return (mid + 1)  
        elif (ar[mid] != mid + 1): 
            r = mid - 1 
        else: 
            l = mid + 1
    return (-1)