Skip to content

Commit 90b61c9

Browse files
authored
Create queries-on-number-of-points-inside-a-circle.py
1 parent 8e52c1f commit 90b61c9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Time: O(q * n)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def countPoints(self, points, queries):
6+
"""
7+
:type points: List[List[int]]
8+
:type queries: List[List[int]]
9+
:rtype: List[int]
10+
"""
11+
result = []
12+
for i, j, r in queries:
13+
result.append(0)
14+
for x, y in points:
15+
if (x-i)**2+(y-j)**2 <= r**2:
16+
result[-1] += 1
17+
return result

0 commit comments

Comments
 (0)