Python solution O(m*n) and beat 55%


  • 0

    It is very simple so I wish you can do better.

    class Solution(object):
        def searchMatrix(self, matrix, target):
            """
            :type matrix: List[List[int]]
            :type target: int
            :rtype: bool
            """
            for i in matrix:
                if target > i[-1]:
                    continue
                if target in i:
                    return True
            return False
    

Log in to reply
 

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