aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x2610/main.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/2610/main.py b/2610/main.py
new file mode 100755
index 0000000..5855490
--- /dev/null
+++ b/2610/main.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+import typing
+
+
+class Solution:
+ def findMatrix(self, nums: typing.List[int]) -> typing.List[typing.List[int]]:
+ dicts = {}
+ for num in nums:
+ if num in dicts:
+ dicts[num] += 1
+ else:
+ dicts[num] = 1
+
+ row = 0
+ results = []
+ for i in range(max(dicts.values())):
+ results.append([])
+ while max(dicts.values()) > 0:
+ for k, v in dicts.items():
+ if v >= 1:
+ results[row].append(k)
+ dicts[k] -= 1
+ row += 1
+
+ return results
+
+
+def main():
+ s = Solution()
+ print(s.findMatrix([1, 3, 4, 1, 2, 3, 1]))
+ print(s.findMatrix([1, 2, 3, 4]))
+
+
+if __name__ == "__main__":
+ main()