Simple py code explained in detail! || BFS
Problem Understanding\n\n- This is one of my favourite Math,geometry problem.Let\'s undersatnd the question!\n- They have given a list of list  named bombs.It c
# Problem Understanding\n\n- This is one of my favourite Math,geometry problem.Let\'s undersatnd the question!\n- They have given a *list of list*  named `bombs`.It contains it\'s location and radius as `[x,y,r]`.\n- We can detonate any bomb,and find the `maximum` number of bombs which will be detonated.\n- A `bomb` is *triggered* if it is in `radius` of another bombs which is being *exploded*.\n- So this problem can be solved in `BFS` or `DFS`.\n---\n\n\n# Approach:BFS\n<!-- Describe your approach to solving the problem. -->\n# Intuition and explantion:\n<!-- Describe your first thoughts on how to solve this problem. -->\n- The idea is simple,we will use `BFS` to all the *bomb* in `bombs`\n the one with `maximum` number of bombs exploded which is the result of our `BFS` will be our solution.\n- ***WHAT\'S THE PROBLEM?*** How to decide which is in our bomb\'s exlosive radius!\n- The ans to this is not tricky,what I did I stored all the distance from one `bomb` to another `bomb` in `distance` matrix of size `l*l`,where `l` is the no of `bombs`.\n- let\'s talk how I did by `BFS` before talking how *eplosion* logic works.while calling `BFS` I required only which bomb I am exploding which is `i` and the `radius-->bombs[i][-1]`.In the queue I stored the same as *tuple*!\n- `visited` stores no of `bombs` which got exploded.\n- The bomb explodes only when the `r` radius of the current bomb which is `idx` is greater than the distance between the `two` bombs\n`i` and `idx` which is calculated from `distance` matrix.\n- `countMax` stores the maximum no of bombs detonated which is calculated by counting no of `visited` in `BFS`.\n\n# Complexity\n- Time complexity:$O(N^2)$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$O(N^2)$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n    def maximumDetonation(self, bombs: List[List[int]]) -> int:\n        def distanceCal(x1,y1,x2,y2):\n            return math.sqrt((x2-x1)**2+(y2-y1)**2)\n        def display(mat):\n            for row in mat:\n                print(row)\n            print(\'-------------------\')\n        #BFS\n        def BFS(r,i):\n            l=len(bombs)\n            visited=[False]*l\n            visited[i]=True\n            q=deque([(r,i)])\n            while q:\n                l=len(q)\n                r,idx=q.popleft()\n                for i in range(len(bombs)):\n                    if not visited[i] and r-distance[idx][i]>=0:\n                        q.append((bombs[i][-1],i))\n                        visited[i]=True\n            return visited.count(True)\n        #distance calculation!\n        l=len(bombs)\n        distance=[[0]*l for _ in range(l)]\n        display(distance)\n        for i in range(l):\n            for j in range(l):\n                distance[i][j]=distanceCal(bombs[i][0],bombs[i][1],bombs[j][0],bombs[j][1])\n        display(distance)\n        #logic\n        countMax=1\n        for i in range(len(bombs)):\n            countMax=max(countMax,BFS(bombs[i][-1],i))\n        return countMax\n\n```\n\n---\n\n\n##### PS:I solved this in `22:03`minutes!
['Array', 'Math', 'Breadth-First Search', 'Graph', 'Geometry', 'Python3']