aboutsummaryrefslogtreecommitdiffstats
path: root/2610/main.py
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2024-01-02 01:32:28 +0000
committerterminaldweller <devi@terminaldweller.com>2024-01-02 01:32:28 +0000
commit3968cebfa1dff618488c68a2f10e0afea9e3fb53 (patch)
treef8dc4bba303c93451a9bdac7d98f137452234a64 /2610/main.py
parent192 (diff)
downloadleetcode-3968cebfa1dff618488c68a2f10e0afea9e3fb53.tar.gz
leetcode-3968cebfa1dff618488c68a2f10e0afea9e3fb53.zip
2610
Diffstat (limited to '2610/main.py')
-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()