Skip to content

Commit a8eb54b

Browse files
authored
Update Search a 2D Matrix - Leetcode 74.py
1 parent b44ea2b commit a8eb54b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Search a 2D Matrix - Leetcode 74/Search a 2D Matrix - Leetcode 74.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# Brute Force Solution
2+
class Solution:
3+
def searchMatrix(self, matrix: List[List[int]], target: int) -> bool:
4+
for row in matrix:
5+
if target in row:
6+
return True
7+
8+
return False
9+
# Time: O(m * n)
10+
# Space: O(1)
11+
12+
# Optimal Solution
113
class Solution:
214
def searchMatrix(self, matrix: List[List[int]], target: int) -> bool:
315
m = len(matrix)

0 commit comments

Comments
 (0)