We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8ad0ece commit e780019Copy full SHA for e780019
1 file changed
find_elements_in_matrix.py
@@ -0,0 +1,24 @@
1
+# coding: utf-8
2
+
3
+class Solution:
4
+ """
5
+ @param Matrix: the input
6
+ @return: the element which appears every row
7
8
+ def FindElements(self, Matrix):
9
+ # write your code here
10
+ di = {}
11
+ for row in Matrix:
12
+ rc = {}
13
+ for i in row:
14
+ rc[i] = 1
15
+ for k in rc.keys():
16
+ if k in di:
17
+ di[k] += 1
18
+ else:
19
+ di[k] = 1
20
+ for k, v in di.items():
21
+ if v == len(Matrix):
22
+ return k
23
24
+# easy: http://lintcode.com/zh-cn/problem/find-elements-in-matrix/
0 commit comments