Count Lattice Points Inside a Circle LeetCode solution in Python

1
class Solution:
2
def countLatticePoints(self, c: List[List[int]]) -> int:
3
ans, m = 0, [0] * 40401
4
c = set(((x, y, r) for x, y, r in c))
5
for x, y, r in c:
6
for i in range(x - r, x + r + 1):
7
d = int(sqrt(r * r - (x - i) * (x - i)))
8
m[i * 201 + y - d : i * 201 + y + d + 1] = [1] * (d + d + 1)
9
return sum(m)

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0