From 3968cebfa1dff618488c68a2f10e0afea9e3fb53 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Mon, 1 Jan 2024 20:32:28 -0500 Subject: 2610 --- 2610/main.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 2610/main.py 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() -- cgit v1.2.3