Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    2249 - Count Lattice Points Inside a Circle\.

    Medium

    Given a 2D integer array circles where <code>circlesi = 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 the number of lattice points that are present inside at least one circle.

    Note:

    • A lattice point is a point with integer coordinates.

    • Points that lie on the circumference of a circle are also considered to be inside it.

    Example 1:

    Input: circles = \[\[2,2,1]]

    Output: 5

    Explanation:

    The figure above shows the given circle.

    The lattice points present inside the circle are (1, 2), (2, 1), (2, 2), (2, 3), and (3, 2) and are shown in green.

    Other points such as (1, 1) and (1, 3), which are shown in red, are not considered inside the circle.

    Hence, the number of lattice points present inside at least one circle is 5.

    Example 2:

    Input: circles = \[\[2,2,2],3,4,1]

    Output: 16

    Explanation:

    The figure above shows the given circles.

    There are exactly 16 lattice points which are present inside at least one circle.

    Some of them are (0, 2), (2, 0), (2, 4), (3, 2), and (4, 4).

    Constraints:

    • 1 &lt;= circles.length &lt;= 200

    • circles[i].length == 3

    • <code>1 <= x<sub>i</sub>, y<sub>i</sub><= 100</code>

    • <code>1 <= r<sub>i</sub><= min(x<sub>i</sub>, y<sub>i</sub>)</code>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Integer countLatticePoints(Array<IntArray> circles)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait