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)/统计一个圆中点的数目 [queries-on-number-of-points-inside-a-circle].html
2022-03-29 12:43:11 +08:00

41 lines
2.3 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>给你一个数组 <code>points</code> ,其中 <code>points[i] = [x<sub>i</sub>, y<sub>i</sub>]</code> ,表示第 <code>i</code> 个点在二维平面上的坐标。多个点可能会有 <strong>相同</strong> 的坐标。</p>
<p>同时给你一个数组 <code>queries</code> ,其中 <code>queries[j] = [x<sub>j</sub>, y<sub>j</sub>, r<sub>j</sub>]</code> ,表示一个圆心在 <code>(x<sub>j</sub>, y<sub>j</sub>)</code> 且半径为 <code>r<sub>j</sub></code><sub> </sub>的圆。</p>
<p>对于每一个查询 <code>queries[j]</code> ,计算在第 <code>j</code> 个圆 <strong></strong> 点的数目。如果一个点在圆的 <strong>边界上</strong> ,我们同样认为它在圆 <strong></strong> 。</p>
<p>请你返回一个数组<em> </em><code>answer</code> ,其中<em> </em><code>answer[j]</code>是第 <code>j</code> 个查询的答案。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/03/25/chrome_2021-03-25_22-34-16.png" style="width: 500px; height: 418px;">
<pre><b>输入:</b>points = [[1,3],[3,3],[5,3],[2,2]], queries = [[2,3,1],[4,3,1],[1,1,2]]
<b>输出:</b>[3,2,2]
<b>解释:</b>所有的点和圆如上图所示。
queries[0] 是绿色的圆queries[1] 是红色的圆queries[2] 是蓝色的圆。
</pre>
<p><strong>示例 2</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/03/25/chrome_2021-03-25_22-42-07.png" style="width: 500px; height: 390px;">
<pre><b>输入:</b>points = [[1,1],[2,2],[3,3],[4,4],[5,5]], queries = [[1,2,2],[2,2,2],[4,3,2],[4,3,3]]
<b>输出:</b>[2,3,2,4]
<b>解释:</b>所有的点和圆如上图所示。
queries[0] 是绿色的圆queries[1] 是红色的圆queries[2] 是蓝色的圆queries[3] 是紫色的圆。
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= points.length &lt;= 500</code></li>
<li><code>points[i].length == 2</code></li>
<li><code>0 &lt;= x<sub>i</sub>, y<sub>i</sub> &lt;= 500</code></li>
<li><code>1 &lt;= queries.length &lt;= 500</code></li>
<li><code>queries[j].length == 3</code></li>
<li><code>0 &lt;= x<sub>j</sub>, y<sub>j</sub> &lt;= 500</code></li>
<li><code>1 &lt;= r<sub>j</sub> &lt;= 500</code></li>
<li>所有的坐标都是整数。</li>
</ul>