Given a 2D integer array circles where circles[i] = [xi, yi, ri] represents the center (xi, yi) and radius ri of the ith 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.


&nbsp;
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).


&nbsp;
Constraints:


	1 &lt;= circles.length &lt;= 200
	circles[i].length == 3
	1 &lt;= xi, yi &lt;= 100
	1 &lt;= ri &lt;= min(xi, yi)


class Solution:
    def countLatticePoints(self, c: List[List[int]]) -> int:
        ans,m=0,[0]*40401
        c=set(((x,y,r) for x,y,r in c))
        for x, y, r in c:
            for i in range(x-r, x+r+1):
                d=int(sqrt(r*r-(x-i)*(x-i)))
                m[i*201+y-d:i*201+y+d+1]=[1]*(d+d+1)
        return sum(m)
class Solution {
    public int countLatticePoints(int[][] circles) {
        Set<String> answer = new HashSet<String>();
        
        for (int[] c : circles) {
            int x = c[0], y = c[1], r = c[2];
            
            // traversing over all the points that lie inside the smallest square capable of containing the whole circle
            for (int xx = x - r; xx <= x + r; xx++)
                for (int yy = y - r; yy <= y + r; yy++)
                    if ((r * r) >= ((x - xx) * (x - xx)) + ((y - yy) * (y - yy)))
                        answer.add(xx + ":" + yy);
        }
        
        return answer.size();
    }
}
class Solution {
public:
    bool circle(int x , int y , int c1 , int c2, int r){
        if((x-c1)*(x-c1) + (y-c2)*(y-c2) <= r*r) 
            return true ;
        return false ;
    }
    
    int countLatticePoints(vector<vector<int>>& circles) {
        int n = circles.size() , ans = 0 ;
        set<pair<int,int>> set ;
        for(auto v : circles){
            int r = v[2] , x = v[0] , y = v[1]; 
            for(int i = x-r ; i <= x+r ; i++)
                for(int j = y-r ; j <= y+r ; j++)
                    if(circle(i,j,x,y,r)){
                        pair<int,int> p(i,j) ;
                        set.insert(p) ;
                    }
        }
        return set.size() ;
    }
};
var countLatticePoints = function(circles) {
    let minX=minY=Infinity, maxX=maxY=-Infinity;
    for(let i=0; i<circles.length; i++){
        minX=Math.min(minX, circles[i][0]-circles[i][2]); maxX=Math.max(maxX, circles[i][0]+circles[i][2]);
        minY=Math.min(minY, circles[i][1]-circles[i][2]); maxY=Math.max(maxY, circles[i][1]+circles[i][2]);
    }
	
    let count=0;
    for(let i=minX; i<=maxX; i++){
        for(let j=minY; j<=maxY; j++){
            let find=false;
            for(let k=0; k<circles.length; k++){
                if(((i-circles[k][0])**2+(j-circles[k][1])**2)<=circles[k][2]**2){
                    find=true; break;
                }
            }
            if(find){count++};
        }
    }
    return count;
};
Count Lattice Points Inside a Circle