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)/最长优雅子数组 [longest-nice-subarray].html
2022-09-10 23:46:34 +08:00

38 lines
1.4 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>给你一个由 <strong></strong> 整数组成的数组 <code>nums</code></p>
<p>如果&nbsp;<code>nums</code> 的子数组中位于 <strong>不同</strong> 位置的每对元素按位 <strong>AND</strong>运算的结果等于 <code>0</code> ,则称该子数组为 <strong>优雅</strong> 子数组。</p>
<p>返回 <strong>最长</strong> 的优雅子数组的长度。</p>
<p><strong>子数组</strong> 是数组中的一个 <strong>连续</strong> 部分。</p>
<p><strong>注意:</strong>长度为 <code>1</code> 的子数组始终视作优雅子数组。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>nums = [1,3,8,48,10]
<strong>输出:</strong>3
<strong>解释:</strong>最长的优雅子数组是 [3,8,48] 。子数组满足题目条件:
- 3 AND 8 = 0
- 3 AND 48 = 0
- 8 AND 48 = 0
可以证明不存在更长的优雅子数组,所以返回 3 。</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>nums = [3,1,5,11,13]
<strong>输出:</strong>1
<strong>解释:</strong>最长的优雅子数组长度为 1 ,任何长度为 1 的子数组都满足题目条件。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
</ul>