mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-12 17:05:15 +08:00
53 lines
1.4 KiB
HTML
53 lines
1.4 KiB
HTML
<p>给你一个整数数组 <code>nums</code>。</p>
|
||
|
||
<p>返回数组中所有 <strong>偶数 </strong>的按位 <strong>或</strong> 运算结果。</p>
|
||
|
||
<p>如果 <code>nums</code> 中没有偶数,返回 0。</p>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong class="example">示例 1:</strong></p>
|
||
|
||
<div class="example-block">
|
||
<p><strong>输入:</strong> <span class="example-io">nums = [1,2,3,4,5,6]</span></p>
|
||
|
||
<p><strong>输出:</strong> <span class="example-io">6</span></p>
|
||
|
||
<p><strong>解释:</strong></p>
|
||
|
||
<p>偶数为 2、4 和 6。它们的按位或运算结果是 6。</p>
|
||
</div>
|
||
|
||
<p><strong class="example">示例 2:</strong></p>
|
||
|
||
<div class="example-block">
|
||
<p><strong>输入:</strong> <span class="example-io">nums = [7,9,11]</span></p>
|
||
|
||
<p><strong>输出:</strong> <span class="example-io">0</span></p>
|
||
|
||
<p><strong>解释:</strong></p>
|
||
|
||
<p>数组中没有偶数,因此结果为 0。</p>
|
||
</div>
|
||
|
||
<p><strong class="example">示例 3:</strong></p>
|
||
|
||
<div class="example-block">
|
||
<p><strong>输入:</strong> <span class="example-io">nums = [1,8,16]</span></p>
|
||
|
||
<p><strong>输出:</strong> <span class="example-io">24</span></p>
|
||
|
||
<p><strong>解释:</strong></p>
|
||
|
||
<p>偶数为 8 和 16。它们的按位或运算结果是 24。</p>
|
||
</div>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= nums.length <= 100</code></li>
|
||
<li><code>1 <= nums[i] <= 100</code></li>
|
||
</ul>
|