aboutsummaryrefslogtreecommitdiffstats
path: root/455/main.py
diff options
context:
space:
mode:
Diffstat (limited to '455/main.py')
-rwxr-xr-x455/main.py32
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()