kucheasysa

Algoverse_adesh_21

Jun 19th, 2024
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. class Solution:
  2.     def searchMatrix(self, mat: List[List[int]], target: int) -> bool:
  3.        
  4.         m=len(mat)
  5.         n=len(mat[0])
  6.        
  7.         i=m-1
  8.         j=0
  9.        
  10.         while i>=0 and j<n:
  11.             if mat[i][j]==target:
  12.                 return True
  13.             elif mat[i][j]<target:
  14.                 j+=1
  15.             else:
  16.                 i-=1
  17.                
  18.         return False
Advertisement
Add Comment
Please, Sign In to add comment