Demo entry 5865406

leetcode

   

Submitted by anonymous on Aug 24, 2016 at 05:20
Language: Python. Code size: 461 Bytes.

class Solution(object):
    def searchMatrix(self, matrix, target):
        """
        :type matrix: List[List[int]]
        :type target: int
        :rtype: bool
        """
        if not len(matrix) or not len(matrix[0]): return False
        n,m,c=0,len(matrix[0])-1,len(matrix)
        while(n<c and m>=0):
            if matrix[n][m]>target: m-=1
            elif matrix[n][m]<target: n+=1
            else: return True
        return False

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).