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)/一和零 [ones-and-zeroes].html
2022-03-29 12:43:11 +08:00

38 lines
1.5 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>给你一个二进制字符串数组 <code>strs</code> 和两个整数 <code>m</code><code>n</code></p>
<div class="MachineTrans-Lines">
<p class="MachineTrans-lang-zh-CN">请你找出并返回 <code>strs</code> 的最大子集的长度,该子集中 <strong>最多</strong><code>m</code><code>0</code><code>n</code><code>1</code></p>
<p class="MachineTrans-lang-zh-CN">如果 <code>x</code> 的所有元素也是 <code>y</code> 的元素,集合 <code>x</code> 是集合 <code>y</code><strong>子集</strong></p>
</div>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>strs = ["10", "0001", "111001", "1", "0"], m = 5, n = 3
<strong>输出:</strong>4
<strong>解释:</strong>最多有 5 个 0 和 3 个 1 的最大子集是 {"10","0001","1","0"} ,因此答案是 4 。
其他满足题意但较小的子集包括 {"0001","1"} 和 {"10","1","0"} 。{"111001"} 不满足题意,因为它含 4 个 1 ,大于 n 的值 3 。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>strs = ["10", "0", "1"], m = 1, n = 1
<strong>输出:</strong>2
<strong>解释:</strong>最大的子集是 {"0", "1"} ,所以答案是 2 。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= strs.length &lt;= 600</code></li>
<li><code>1 &lt;= strs[i].length &lt;= 100</code></li>
<li><code>strs[i]</code>&nbsp;仅由&nbsp;<code>'0'</code>&nbsp;<code>'1'</code> 组成</li>
<li><code>1 &lt;= m, n &lt;= 100</code></li>
</ul>