1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/分配重复整数 [distribute-repeating-integers].html
2022-03-29 12:43:11 +08:00

50 lines
2.0 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>给你一个长度为&nbsp;<code>n</code>&nbsp;的整数数组&nbsp;<code>nums</code>&nbsp;,这个数组中至多有&nbsp;<code>50</code>&nbsp;个不同的值。同时你有 <code>m</code>&nbsp;个顾客的订单 <code>quantity</code>&nbsp;,其中,整数&nbsp;<code>quantity[i]</code>&nbsp;是第&nbsp;<code>i</code>&nbsp;位顾客订单的数目。请你判断是否能将 <code>nums</code>&nbsp;中的整数分配给这些顾客,且满足:</p>
<ul>
<li>&nbsp;<code>i</code>&nbsp;位顾客 <strong>恰好&nbsp;</strong>&nbsp;<code>quantity[i]</code>&nbsp;个整数。</li>
<li>&nbsp;<code>i</code>&nbsp;位顾客拿到的整数都是 <strong>相同的</strong>&nbsp;</li>
<li>每位顾客都满足上述两个要求。</li>
</ul>
<p>如果你可以分配 <code>nums</code>&nbsp;中的整数满足上面的要求,那么请返回&nbsp;<code>true</code>&nbsp;,否则返回 <code>false</code>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<b>输入:</b>nums = [1,2,3,4], quantity = [2]
<b>输出:</b>false
<strong>解释:</strong>第 0 位顾客没办法得到两个相同的整数。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<b>输入:</b>nums = [1,2,3,3], quantity = [2]
<b>输出:</b>true
<b>解释:</b>第 0 位顾客得到 [3,3] 。整数 [1,2] 都没有被使用。
</pre>
<p><strong>示例 3</strong></p>
<pre>
<b>输入:</b>nums = [1,1,2,2], quantity = [2,2]
<b>输出:</b>true
<b>解释:</b>第 0 位顾客得到 [1,1] ,第 1 位顾客得到 [2,2] 。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>n == nums.length</code></li>
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 1000</code></li>
<li><code>m == quantity.length</code></li>
<li><code>1 &lt;= m &lt;= 10</code></li>
<li><code>1 &lt;= quantity[i] &lt;= 10<sup>5</sup></code></li>
<li><code>nums</code>&nbsp;中至多有&nbsp;<code>50</code>&nbsp;个不同的数字。</li>
</ul>