def bin_search(self, A, t, lower=True):
        lo = 0
        hi = len(A)
        while lo < hi:
            mid = (lo+hi)/2
            if A[mid] == t:
                return mid
            elif A[mid] < t:
                lo = mid+1
            else:
                hi = mid

        if lower:
            return lo-1
        else:
            return lo
dataset/ETHPy150Open algorhythms/LeetCode/240 Search a 2D Matrix II.py/SolutionBinSearch.bin_search/original