We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c8f5c29 commit 54ae8afCopy full SHA for 54ae8af
maximum_and_minimum.py
@@ -0,0 +1,19 @@
1
+class Solution:
2
+ """
3
+ @param matrix: an input matrix
4
+ @return: nums[0]: the maximum,nums[1]: the minimum
5
6
+ def maxAndMin(self, matrix):
7
+ # write your code here
8
+ if not matrix:
9
+ return []
10
+ r = [matrix[0][0], matrix[0][0]]
11
+ for row in matrix:
12
+ for i in row:
13
+ if i > r[0]: # 确保max在前min在后
14
+ r[0] = i
15
+ elif i < r[1]:
16
+ r[1] = i
17
+ return r
18
+
19
+# easy: https://www.lintcode.com/problem/maximum-and-minimum
0 commit comments