mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-10 01:41:41 +08:00
46 lines
1.3 KiB
HTML
46 lines
1.3 KiB
HTML
<p>给定一个整数数组<meta charset="UTF-8" /> <code>arr</code>,返回所有 <code>arr</code> 的非空子数组的不同按位或的数量。</p>
|
||
|
||
<p>子数组的按位或是子数组中每个整数的按位或。含有一个整数的子数组的按位或就是该整数。</p>
|
||
|
||
<p><strong>子数组</strong> 是数组内连续的非空元素序列。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>示例 1:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>arr = [0]
|
||
<strong>输出:</strong>1
|
||
<strong>解释:</strong>
|
||
只有一个可能的结果 0 。
|
||
</pre>
|
||
|
||
<p><strong>示例 2:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>arr = [1,1,2]
|
||
<strong>输出:</strong>3
|
||
<strong>解释:</strong>
|
||
可能的子数组为 [1],[1],[2],[1, 1],[1, 2],[1, 1, 2]。
|
||
产生的结果为 1,1,2,1,3,3 。
|
||
有三个唯一值,所以答案是 3 。
|
||
</pre>
|
||
|
||
<p><strong>示例 3:</strong></p>
|
||
|
||
<pre>
|
||
<strong>输入:</strong>arr = [1,2,4]
|
||
<strong>输出:</strong>6
|
||
<strong>解释:</strong>
|
||
可能的结果是 1,2,3,4,6,以及 7 。
|
||
</pre>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong><meta charset="UTF-8" /></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= nums.length <= 5 * 10<sup>4</sup></code></li>
|
||
<li><code>0 <= nums[i] <= 10<sup>9</sup></code></li>
|
||
</ul>
|