Skip to content

Commit e6db441

Browse files
committed
update
1 parent 4fc64ad commit e6db441

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

P112. 搜索二维矩阵.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
![algo48](./images/algo48.jpg)
2+
3+
```
4+
class Solution(object):
5+
def searchMatrix(self, matrix, target):
6+
"""
7+
:type matrix: List[List[int]]
8+
:type target: int
9+
:rtype: bool
10+
"""
11+
12+
row = len(matrix)-1
13+
col = 0
14+
start = matrix[row][col]
15+
16+
while (row>=0 and col < len(matrix[0])):
17+
if matrix[row][col] < target:
18+
col += 1
19+
elif matrix[row][col] > target:
20+
row -= 1
21+
else:
22+
return True
23+
return False
24+
```

images/algo48.jpg

46.3 KB
Loading

0 commit comments

Comments
 (0)