link to question:

My Approach:

usinfg DFS with boolean array.As i traverse through graph for a node,i visit only nodes which are not visited till now and not lies in any one of the circle.and this process goes on for every visited node.

At last i check whether given node is visited or not.

my code passed base test cases.

but it gives runtime error(maximum rrecursion depth) for this case:

A : 41

B : 67

C : 5

D : 0

E : [ 17, 16, 12, 0, 40 ]

F : [ 52, 61, 61, 25, 31 ]

i am not able to find the bug?please help me

my code:

def solve(A, B, C, D, E, F):

```
boo = [[0 for k in range(A+1)] for i in range(B+1)]
def dfs(x,y):
boo[y][x] = 1
nei_x = [-1,0,1,-1,1,-1,0,1]
nei_y = [1,1,1,0,0,-1,-1,-1]
for nei in range(8):
va1 = x+nei_x[nei]
va2 = y+nei_y[nei]
bo = False
if 0<=va1<=A and 0<=va2<=B:
for cir in range(C):
va_1 = (va1-E[cir])*(va1-E[cir])
va_2 = (va2-F[cir])*(va2-F[cir])
if va_1+va_2 <= (D*D):
bo = True
if bo==True:
boo[va2][va1] = -1
if boo[va2][va1] == 0:
dfs(va1,va2)
dfs(0,0)
if boo[B][A] == 1:
return "YES"
return 'NO'
```