Skip to content

Commit 451cbfb

Browse files
authored
Create searchMatrixII.py
1 parent 8cc189a commit 451cbfb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

searchMatrixII.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution:
2+
def searchMatrix(self, matrix: List[List[int]], target: int) -> bool:
3+
r = 0
4+
c = len(matrix[0]) - 1
5+
6+
while r < len(matrix) and c >= 0:
7+
if matrix[r][c] == target:
8+
return True
9+
if target < matrix[r][c]:
10+
c -= 1
11+
else:
12+
r += 1
13+
14+
return False
15+

0 commit comments

Comments
 (0)