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)/数组美丽值求和 [sum-of-beauty-in-the-array].html
2022-03-29 12:43:11 +08:00

46 lines
1.7 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>给你一个下标从 <strong>0</strong> 开始的整数数组 <code>nums</code> 。对于每个下标 <code>i</code><code>1 &lt;= i &lt;= nums.length - 2</code><code>nums[i]</code><strong>美丽值</strong> 等于:</p>
<ul>
<li><code>2</code>,对于所有 <code>0 &lt;= j &lt; i</code><code>i &lt; k &lt;= nums.length - 1</code> ,满足 <code>nums[j] &lt; nums[i] &lt; nums[k]</code></li>
<li><code>1</code>,如果满足 <code>nums[i - 1] &lt; nums[i] &lt; nums[i + 1]</code> ,且不满足前面的条件</li>
<li><code>0</code>,如果上述条件全部不满足</li>
</ul>
<p>返回符合 <code>1 &lt;= i &lt;= nums.length - 2</code> 的所有<em> </em><code>nums[i]</code><em> </em><strong>美丽值的总和</strong></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>nums = [1,2,3]
<strong>输出:</strong>2
<strong>解释:</strong>对于每个符合范围 1 &lt;= i &lt;= 1 的下标 i :
- nums[1] 的美丽值等于 2
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>nums = [2,4,6,4]
<strong>输出:</strong>1
<strong>解释:</strong>对于每个符合范围 1 &lt;= i &lt;= 2 的下标 i :
- nums[1] 的美丽值等于 1
- nums[2] 的美丽值等于 0
</pre>
<p><strong>示例 3</strong></p>
<pre><strong>输入:</strong>nums = [3,2,1]
<strong>输出:</strong>0
<strong>解释:</strong>对于每个符合范围 1 &lt;= i &lt;= 1 的下标 i :
- nums[1] 的美丽值等于 0
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>3 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>5</sup></code></li>
</ul>