Class Solution
java.lang.Object
g2201_2300.s2249_count_lattice_points_inside_a_circle.Solution
2249 - Count Lattice Points Inside a Circle.<p>Medium</p>
<p>Given a 2D integer array <code>circles</code> where <code>circles[i] = [x<sub>i</sub>, y<sub>i</sub>, r<sub>i</sub>]</code> represents the center <code>(x<sub>i</sub>, y<sub>i</sub>)</code> and radius <code>r<sub>i</sub></code> of the <code>i<sup>th</sup></code> circle drawn on a grid, return <em>the <strong>number of lattice points</strong></em> <em>that are present inside <strong>at least one</strong> circle</em>.</p>
<p><strong>Note:</strong></p>
<ul>
<li>A <strong>lattice point</strong> is a point with integer coordinates.</li>
<li>Points that lie <strong>on the circumference of a circle</strong> are also considered to be inside it.</li>
</ul>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2022/03/02/exa-11.png" alt="" /></p>
<p><strong>Input:</strong> circles = [[2,2,1]]</p>
<p><strong>Output:</strong> 5</p>
<p><strong>Explanation:</strong></p>
<p>The figure above shows the given circle.</p>
<p>The lattice points present inside the circle are (1, 2), (2, 1), (2, 2), (2, 3), and (3, 2) and are shown in green.</p>
<p>Other points such as (1, 1) and (1, 3), which are shown in red, are not considered inside the circle.</p>
<p>Hence, the number of lattice points present inside at least one circle is 5.</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2022/03/02/exa-22.png" alt="" /></p>
<p><strong>Input:</strong> circles = [[2,2,2],[3,4,1]]</p>
<p><strong>Output:</strong> 16</p>
<p><strong>Explanation:</strong></p>
<p>The figure above shows the given circles.</p>
<p>There are exactly 16 lattice points which are present inside at least one circle.</p>
<p>Some of them are (0, 2), (2, 0), (2, 4), (3, 2), and (4, 4).</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= circles.length <= 200</code></li>
<li><code>circles[i].length == 3</code></li>
<li><code>1 <= x<sub>i</sub>, y<sub>i</sub> <= 100</code></li>
<li><code>1 <= r<sub>i</sub> <= min(x<sub>i</sub>, y<sub>i</sub>)</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
countLatticePoints
public int countLatticePoints(int[][] circles)
-