|
| 1 | +<p>The <strong>bitwise AND</strong> of an array <code>nums</code> is the bitwise AND of all integers in <code>nums</code>.</p> |
| 2 | + |
| 3 | +<ul> |
| 4 | + <li>For example, for <code>nums = [1, 5, 3]</code>, the bitwise AND is equal to <code>1 & 5 & 3 = 1</code>.</li> |
| 5 | + <li>Also, for <code>nums = [7]</code>, the bitwise AND is <code>7</code>.</li> |
| 6 | +</ul> |
| 7 | + |
| 8 | +<p>You are given an array of positive integers <code>candidates</code>. Evaluate the <strong>bitwise AND</strong> of every <strong>combination</strong> of numbers of <code>candidates</code>. Each number in <code>candidates</code> may only be used <strong>once</strong> in each combination.</p> |
| 9 | + |
| 10 | +<p>Return <em>the size of the <strong>largest</strong> combination of </em><code>candidates</code><em> with a bitwise AND <strong>greater</strong> than </em><code>0</code>.</p> |
| 11 | + |
| 12 | +<p> </p> |
| 13 | +<p><strong class="example">Example 1:</strong></p> |
| 14 | + |
| 15 | +<pre> |
| 16 | +<strong>Input:</strong> candidates = [16,17,71,62,12,24,14] |
| 17 | +<strong>Output:</strong> 4 |
| 18 | +<strong>Explanation:</strong> The combination [16,17,62,24] has a bitwise AND of 16 & 17 & 62 & 24 = 16 > 0. |
| 19 | +The size of the combination is 4. |
| 20 | +It can be shown that no combination with a size greater than 4 has a bitwise AND greater than 0. |
| 21 | +Note that more than one combination may have the largest size. |
| 22 | +For example, the combination [62,12,24,14] has a bitwise AND of 62 & 12 & 24 & 14 = 8 > 0. |
| 23 | +</pre> |
| 24 | + |
| 25 | +<p><strong class="example">Example 2:</strong></p> |
| 26 | + |
| 27 | +<pre> |
| 28 | +<strong>Input:</strong> candidates = [8,8] |
| 29 | +<strong>Output:</strong> 2 |
| 30 | +<strong>Explanation:</strong> The largest combination [8,8] has a bitwise AND of 8 & 8 = 8 > 0. |
| 31 | +The size of the combination is 2, so we return 2. |
| 32 | +</pre> |
| 33 | + |
| 34 | +<p> </p> |
| 35 | +<p><strong>Constraints:</strong></p> |
| 36 | + |
| 37 | +<ul> |
| 38 | + <li><code>1 <= candidates.length <= 10<sup>5</sup></code></li> |
| 39 | + <li><code>1 <= candidates[i] <= 10<sup>7</sup></code></li> |
| 40 | +</ul> |
0 commit comments