Python BFS Faster than 96%
Create a dictionary: the key is the index of each bomb, value is the indexes of all the bombs which the key bomb could detonate;\n2. Use BFS to calculate the nu
1. Create a dictionary: the key is the index of each bomb, value is the indexes of all the bombs which the key bomb could detonate;\n2. Use BFS to calculate the number of bombs \n3. **No need to loop for all the keys in the dictionary,** for example:\nif bombs[3] can detonate bombs[4], bombs[5], bombs[6], so there is no need to calculate the detonated quantity of bombs 4,5 and 6;\ncause this question requires returning the maximum quantity detonated, and the number of bombs 4, 5, and 6 will no more than that of bomb 3.\n**so the looped bomb list should be keeping removing all the sub-detonated bombs after each iteration.**\n\n    Please leave messages if you get any questions or suggestions. Thank you.\n\nclass Solution:\n    def maximumDetonation(self, bombs: List[List[int]]) -> int:\n        \n        \n        cnt,n=0,len(bombs)\n        ori=set(range(n))\n        dic={}\n        for i in range(n):\n            dic[i]=set()\n        \n        for i in range(n):\n            [x1,y1,r1]=bombs[i]\n            for j in range(i+1,n):\n                [x2,y2,r2]=bombs[j]\n                \n                sqare_distance=pow(x1-x2,2)+pow(y1-y2,2)                \n                if sqare_distance<=pow(r1,2):\n                    dic[i].add(j)\n                if sqare_distance<=pow(r2,2):\n                    dic[j].add(i)\n                \n        while ori:\n            i=ori.pop()\n            cur=diff=dic[i]          \n            cur.add(i)\n            pre=cur           \n                        \n            while diff:                \n                for next in diff:\n                    cur=cur|dic[next]                    \n                \n                diff=cur-pre\n                pre=cur              \n            \n            ori-=pre                           // step 3          \n            cnt=max(cnt,len(cur))\n                \n        return cnt
['Breadth-First Search', 'Python']