148. Leetcode 455. 分发饼干 (贪心算法-基础题目)
生活随笔
收集整理的這篇文章主要介紹了
148. Leetcode 455. 分发饼干 (贪心算法-基础题目)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
class Solution:def findContentChildren(self, g: List[int], s: List[int]) -> int:g.sort()s.sort()m = len(s)n = len(g)i = j = count = 0while i< n and j < m:while j < m and g[i] > s[j]:j += 1if j < m:count += 1i += 1j += 1return count總結
以上是生活随笔為你收集整理的148. Leetcode 455. 分发饼干 (贪心算法-基础题目)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 146. Leetcode 51. N
- 下一篇: 149. Leetcode 1005.