diff options
author | terminaldweller <devi@terminaldweller.com> | 2024-01-01 16:09:43 +0000 |
---|---|---|
committer | terminaldweller <devi@terminaldweller.com> | 2024-01-01 16:09:43 +0000 |
commit | 33be59cad98d618dc6778122405ffe7186045df0 (patch) | |
tree | 40768286feafe34da65911821c973e663c8449f5 /455 | |
parent | 1624 (diff) | |
download | leetcode-33be59cad98d618dc6778122405ffe7186045df0.tar.gz leetcode-33be59cad98d618dc6778122405ffe7186045df0.zip |
455
Diffstat (limited to '455')
-rwxr-xr-x | 455/main.py | 32 |
1 files changed, 32 insertions, 0 deletions
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() |