1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-07 00:11:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/problem (Chinese)/分发饼干 [assign-cookies].html
2025-01-09 20:29:41 +08:00

41 lines
1.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>假设你是一位很棒的家长,想要给你的孩子们一些小饼干。但是,每个孩子最多只能给一块饼干。</p>
<p>对每个孩子 <code>i</code>,都有一个胃口值&nbsp;<code>g[i]</code><sub></sub>这是能让孩子们满足胃口的饼干的最小尺寸;并且每块饼干 <code>j</code>,都有一个尺寸 <code>s[j]</code><sub>&nbsp;</sub>。如果 <code>s[j]&nbsp;&gt;= g[i]</code>,我们可以将这个饼干 <code>j</code> 分配给孩子 <code>i</code> ,这个孩子会得到满足。你的目标是满足尽可能多的孩子,并输出这个最大数值。</p>
&nbsp;
<p><strong>示例&nbsp;1:</strong></p>
<pre>
<strong>输入:</strong> g = [1,2,3], s = [1,1]
<strong>输出:</strong> 1
<strong>解释:</strong>
你有三个孩子和两块小饼干3 个孩子的胃口值分别是1,2,3。
虽然你有两块小饼干,由于他们的尺寸都是 1你只能让胃口值是 1 的孩子满足。
所以你应该输出 1。
</pre>
<p><strong>示例&nbsp;2:</strong></p>
<pre>
<strong>输入:</strong> g = [1,2], s = [1,2,3]
<strong>输出:</strong> 2
<strong>解释:</strong>
你有两个孩子和三块小饼干2 个孩子的胃口值分别是 1,2。
你拥有的饼干数量和尺寸都足以让所有孩子满足。
所以你应该输出 2。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= g.length &lt;= 3 * 10<sup>4</sup></code></li>
<li><code>0 &lt;= s.length &lt;= 3 * 10<sup>4</sup></code></li>
<li><code>1 &lt;= g[i], s[j] &lt;=&nbsp;2<sup>31</sup> - 1</code></li>
</ul>
<p>&nbsp;</p>
<p><strong>注意:</strong>本题与&nbsp;<a href="https://leetcode.cn/problems/maximum-matching-of-players-with-trainers/">2410. 运动员和训练师的最大匹配数</a>&nbsp;题相同。</p>