mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
38 lines
1.1 KiB
HTML
38 lines
1.1 KiB
HTML
<p>给定2D空间中四个点的坐标 <code>p1</code>, <code>p2</code>, <code>p3</code> 和 <code>p4</code>,如果这四个点构成一个正方形,则返回 <code>true</code> 。</p>
|
|
|
|
<p>点的坐标 <code>p<sub>i</sub></code> 表示为 <code>[xi, yi]</code> 。输入 <strong>不是</strong> 按任何顺序给出的。</p>
|
|
|
|
<p>一个 <strong>有效的正方形</strong> 有四条等边和四个等角(90度角)。</p>
|
|
|
|
<p> </p>
|
|
|
|
<p><strong>示例 1:</strong></p>
|
|
|
|
<pre>
|
|
<strong>输入:</strong> p1 = [0,0], p2 = [1,1], p3 = [1,0], p4 = [0,1]
|
|
<strong>输出:</strong> True
|
|
</pre>
|
|
|
|
<p><strong>示例 2:</strong></p>
|
|
|
|
<pre>
|
|
<strong>输入:</strong>p1 = [0,0], p2 = [1,1], p3 = [1,0], p4 = [0,12]
|
|
<b>输出:</b>false
|
|
</pre>
|
|
|
|
<p><strong>示例 3:</strong></p>
|
|
|
|
<pre>
|
|
<b>输入:</b>p1 = [1,0], p2 = [-1,0], p3 = [0,1], p4 = [0,-1]
|
|
<b>输出:</b>true
|
|
</pre>
|
|
|
|
<p> </p>
|
|
|
|
<p><strong>提示:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>p1.length == p2.length == p3.length == p4.length == 2</code></li>
|
|
<li><code>-10<sup>4</sup> <= x<sub>i</sub>, y<sub>i</sub> <= 10<sup>4</sup></code></li>
|
|
</ul>
|