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)/判断能否形成等差数列 [can-make-arithmetic-progression-from-sequence].html
2022-03-29 12:43:11 +08:00

31 lines
979 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>给你一个数字数组 <code>arr</code></p>
<p>如果一个数列中,任意相邻两项的差总等于同一个常数,那么这个数列就称为 <strong>等差数列</strong></p>
<p>如果可以重新排列数组形成等差数列,请返回 <code>true</code> ;否则,返回 <code>false</code></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>arr = [3,5,1]
<strong>输出:</strong>true
<strong>解释:</strong>对数组重新排序得到 [1,3,5] 或者 [5,3,1] ,任意相邻两项的差分别为 2 或 -2 ,可以形成等差数列。
</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>arr = [1,2,4]
<strong>输出:</strong>false
<strong>解释:</strong>无法通过重新排序得到等差数列。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>2 &lt;= arr.length &lt;= 1000</code></li>
<li><code>-10^6 &lt;= arr[i] &lt;= 10^6</code></li>
</ul>