From 33be59cad98d618dc6778122405ffe7186045df0 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Mon, 1 Jan 2024 11:09:43 -0500 Subject: 455 --- 455/main.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 455/main.py (limited to '455') diff --git a/455/main.py b/455/main.py new file mode 100755 index 0000000..195c137 --- /dev/null +++ b/455/main.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +import typing + + +class Solution: + def findContentChildren(self, g: typing.List[int], s: typing.List[int]) -> int: + g = sorted(g) + s = sorted(s) + g_idx = 0 + s_idx = 0 + count = 0 + + while s_idx < len(s) and g_idx < len(g): + if s[s_idx] >= g[g_idx]: + count += 1 + s_idx += 1 + g_idx += 1 + else: + s_idx += 1 + + return count + + +def main(): + solution = Solution() + print(solution.findContentChildren([1, 2, 3], [1, 1])) + print(solution.findContentChildren([1, 2], [1, 2, 3])) + + +if __name__ == "__main__": + main() -- cgit v1.2.3