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)/等差数列划分 [arithmetic-slices].html
2022-03-29 12:43:11 +08:00

40 lines
1.0 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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>至少有三个元素</strong> ,并且任意两个相邻元素之差相同,则称该数列为等差数列。</p>
<ul>
<li>例如,<code>[1,3,5,7,9]</code><code>[7,7,7,7]</code><code>[3,-1,-5,-9]</code> 都是等差数列。</li>
</ul>
<div class="original__bRMd">
<div>
<p>给你一个整数数组 <code>nums</code> ,返回数组 <code>nums</code> 中所有为等差数组的 <strong>子数组</strong> 个数。</p>
<p><strong>子数组</strong> 是数组中的一个连续序列。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [1,2,3,4]
<strong>输出:</strong>3
<strong>解释:</strong>nums 中有三个子等差数组:[1, 2, 3]、[2, 3, 4] 和 [1,2,3,4] 自身。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [1]
<strong>输出:</strong>0
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= nums.length <= 5000</code></li>
<li><code>-1000 <= nums[i] <= 1000</code></li>
</ul>
</div>
</div>