1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/可被三整除的最大和 [greatest-sum-divisible-by-three].html
2022-03-29 12:43:11 +08:00

36 lines
985 B
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>,请你找出并返回能被三整除的元素最大和。</p>
<ol>
</ol>
<p>&nbsp;</p>
<p><strong>示例 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>示例 2</strong></p>
<pre><strong>输入:</strong>nums = [4]
<strong>输出:</strong>0
<strong>解释:</strong>4 不能被 3 整除,所以无法选出数字,返回 0。
</pre>
<p><strong>示例 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^4</code></li>
<li><code>1 &lt;= nums[i] &lt;= 10^4</code></li>
</ul>