Count Lattice Points Inside a Circle LeetCode solution in Python
1class Solution:2def countLatticePoints(self, c: List[List[int]]) -> int:3ans, m = 0, [0] * 404014c = set(((x, y, r) for x, y, r in c))5for x, y, r in c:6for i in range(x - r, x + r + 1):7d = int(sqrt(r * r - (x - i) * (x - i)))8m[i * 201 + y - d : i * 201 + y + d + 1] = [1] * (d + d + 1)9return sum(m)