straightforward solution in python


  • 0
    X
    class Solution(object):
        def searchMatrix(self, matrix, target):
            """
            :type matrix: List[List[int]]
            :type target: int
            :rtype: bool
            """
            l = len(matrix)
            c = 0
            if matrix:
                for i in range(l):
                    if target in matrix[i]:
                        return True
                    else:
                        c += 1
                        continue
                if c == l:
                    return False
            else:
                return False
    

Log in to reply
 

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