Simple AC Python Solution

  • 0
    class Solution(object):
        def binarysearch(self,arr,target):
            while i<=j:
                mid = (i+j)/2
                if arr[mid] == target:return True
                if arr[mid] < target: i = mid + 1
                else: j = mid - 1
            return False
        def searchMatrix(self, matrix, target):
            :type matrix: List[List[int]]
            :type target: int
            :rtype: bool
            for i in matrix:
                if self.binarysearch(i,target):return True
            return False

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.