one line Python solution


  • 0
    class Solution(object):
        def searchMatrix(self, matrix, target):
            """
            :type matrix: List[List[int]]
            :type target: int
            :rtype: bool
            """
            return any(target in row for row in matrix if target <= row[-1])
    

    This is one-line solution, easy to understand, time complexity could be O(m * n).


Log in to reply
 

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