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)/可被三整除的最大和 [greatest-sum-divisible-by-three].html

39 lines
1.0 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>给你一个整数数组&nbsp;<code>nums</code>,请你找出并返回能被三整除的元素 <strong>最大和</strong></p>
<ol>
</ol>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [3,6,5,1,8]
<strong>输出:</strong>18
<strong>解释:</strong>选出数字 3, 6, 1 和 8它们的和是 18可被 3 整除的最大和)。</pre>
<p><strong class="example">示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [4]
<strong>输出:</strong>0
<strong>解释:</strong>4 不能被 3 整除,所以无法选出数字,返回 0。
</pre>
<p><strong class="example">示例 3</strong></p>
<pre>
<strong>输入:</strong>nums = [1,2,3,4,4]
<strong>输出:</strong>12
<strong>解释:</strong>选出数字 1, 3, 4 以及 4它们的和是 12可被 3 整除的最大和)。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 4 * 10<sup>4</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>4</sup></code></li>
</ul>