From 5b06ba0fad051813e62617794372d89d8bb8e29b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E8=8B=B1=E6=9D=B0?= <327782001@qq.com> Date: Thu, 29 Jun 2023 23:21:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=88=86=E5=8F=91=E9=A5=BC=E5=B9=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../day03/problem_solving_23.py" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "14_\345\210\267\351\242\230/day03/problem_solving_23.py" diff --git "a/14_\345\210\267\351\242\230/day03/problem_solving_23.py" "b/14_\345\210\267\351\242\230/day03/problem_solving_23.py" new file mode 100644 index 0000000..93efc60 --- /dev/null +++ "b/14_\345\210\267\351\242\230/day03/problem_solving_23.py" @@ -0,0 +1,24 @@ +""" +分发饼干 +""" +from typing import List + + +class Solution: + def findContentChildren(self, g: List[int], s: List[int]) -> int: + g.sort() + s.sort() + i = 0 + j = 0 + count = 0 + while i < len(g) and j < len(s): + if g[i] <= s[j]: + count += 1 + i += 1 + j += 1 + return count + + +if __name__ == '__main__': + result = Solution().findContentChildren([1, 2, 3], [1, 1]) + print(result) -- GitLab