1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-10 01:41:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/problem (Chinese)/子数组按位或操作 [bitwise-ors-of-subarrays].html
2025-01-09 20:29:41 +08:00

46 lines
1.3 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>给定一个整数数组<meta charset="UTF-8" />&nbsp;<code>arr</code>,返回所有&nbsp;<code>arr</code>&nbsp;的非空子数组的不同按位或的数量。</p>
<p>子数组的按位或是子数组中每个整数的按位或。含有一个整数的子数组的按位或就是该整数。</p>
<p><strong>子数组</strong> 是数组内连续的非空元素序列。</p>
<p>&nbsp;</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]。
产生的结果为 112133 。
有三个唯一值,所以答案是 3 。
</pre>
<p><strong>示例&nbsp;3</strong></p>
<pre>
<strong>输入:</strong>arr = [1,2,4]
<strong>输出:</strong>6
<strong>解释:</strong>
可能的结果是 12346以及 7 。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong><meta charset="UTF-8" /></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 5 * 10<sup>4</sup></code></li>
<li><code>0 &lt;= nums[i]&nbsp;&lt;= 10<sup>9</sup></code></li>
</ul>