File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ class Solution :
2
+ def setZeroes (self , matrix ):
3
+ """
4
+ :type matrix: List[List[int]]
5
+ :rtype: void Do not return anything, modify matrix in-place instead.
6
+ """
7
+
8
+ coord = []
9
+ for i in range (len (matrix )):
10
+ for j in range (len (matrix [i ])):
11
+ if matrix [i ][j ] == 0 :
12
+ coord .append ((i , j ))
13
+
14
+ for i , j in coord :
15
+ matrix [i ] = [0 ]* len (matrix [i ])
16
+ for x in range (len (matrix )):
17
+ matrix [x ][j ] = 0
Original file line number Diff line number Diff line change
1
+ class Solution :
2
+ def searchMatrix (self , matrix , target ):
3
+ """
4
+ :type matrix: List[List[int]]
5
+ :type target: int
6
+ :rtype: bool
7
+ """
8
+
9
+ if not matrix or not matrix [0 ]:
10
+ return False
11
+
12
+ for row in matrix :
13
+ if row [0 ] <= target <= row [- 1 ]:
14
+ s = 0
15
+ e = len (row )- 1
16
+ while s <= e :
17
+ mid = (s + e )// 2
18
+ if row [mid ] == target :
19
+ return True
20
+ elif row [mid ] > target :
21
+ e = mid - 1
22
+ else :
23
+ s = mid + 1
24
+
25
+ return False
26
+
27
+ return False
You can’t perform that action at this time.
0 commit comments