mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
31 lines
1.4 KiB
HTML
31 lines
1.4 KiB
HTML
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>.</p>
|
|
|
|
<p>We say that an integer x is <strong>expressible</strong> from <code>nums</code> if there exist some integers <code>0 <= index<sub>1</sub> < index<sub>2</sub> < ... < index<sub>k</sub> < nums.length</code> for which <code>nums[index<sub>1</sub>] | nums[index<sub>2</sub>] | ... | nums[index<sub>k</sub>] = x</code>. In other words, an integer is expressible if it can be written as the bitwise OR of some subsequence of <code>nums</code>.</p>
|
|
|
|
<p>Return <em>the minimum <strong>positive non-zero integer</strong> that is not </em><em>expressible from </em><code>nums</code>.</p>
|
|
|
|
<p> </p>
|
|
<p><strong class="example">Example 1:</strong></p>
|
|
|
|
<pre>
|
|
<strong>Input:</strong> nums = [2,1]
|
|
<strong>Output:</strong> 4
|
|
<strong>Explanation:</strong> 1 and 2 are already present in the array. We know that 3 is expressible, since nums[0] | nums[1] = 2 | 1 = 3. Since 4 is not expressible, we return 4.
|
|
</pre>
|
|
|
|
<p><strong class="example">Example 2:</strong></p>
|
|
|
|
<pre>
|
|
<strong>Input:</strong> nums = [5,3,2]
|
|
<strong>Output:</strong> 1
|
|
<strong>Explanation:</strong> We can show that 1 is the smallest number that is not expressible.
|
|
</pre>
|
|
|
|
<p> </p>
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
|
|
<li><code>1 <= nums[i] <= 10<sup>9</sup></code></li>
|
|
</ul>
|