• + 0 comments

    O(n) where n number of pages

    def workbook(n, k, arr):
        m=1
        n=1
        o=0
        acc=0
        while (o != len(arr)):
            le = min(m+k-1, arr[o])
            if (m <= n and n <= le):
                acc+=1
            m = le + 1
            if (m > arr[o]):
                o+=1
                m=1
            n+=1
        return acc