✅ Explained - Simple and Clear Python3 Code✅
Intuition\nThe given problem involves determining the maximum number of bombs that can be detonated if you are allowed to detonate only one bomb. The bombs are 
# Intuition\nThe given problem involves determining the maximum number of bombs that can be detonated if you are allowed to detonate only one bomb. The bombs are represented as a list of 2D integer arrays, where each array contains the X-coordinate, Y-coordinate, and radius of a bomb.\n\n\n# Approach\nTo solve this problem, the provided solution uses a depth-first search (DFS) approach. It first initializes an empty list called "connected" to store the connections between the bombs. Each index in the "connected" list represents a bomb, and the corresponding value is a list of indices of other bombs that can be detonated if the bomb at that index is detonated.\n\nNext, the solution iterates through each bomb and checks its range against the ranges of other bombs. If the range of the current bomb overlaps with the range of another bomb, it adds the index of the other bomb to the "connected" list for the current bomb.\n\nAfter creating the "connected" list, the solution initializes an empty list called "res" to store the results. It also initializes an empty list called "visited" to keep track of the bombs that have been visited during the DFS.\n\nThen, for each bomb, the solution performs a DFS starting from that bomb\'s index. During the DFS, it visits all the connected bombs and adds them to the "visited" list. After completing the DFS, it appends the length of the "visited" list to the "res" list.\n\nFinally, the solution returns the maximum value in the "res" list, which represents the maximum number of bombs that can be detonated if you are allowed to detonate only one bomb.\n\n# Complexity\n- Time complexity:\nThe time complexity of this solution depends on the number of bombs, denoted as "n". The creation of the "connected" list takes O(n^2) time since it involves comparing each bomb\'s range with the ranges of other bombs. The DFS step is performed for each bomb, resulting in a time complexity of O(n^2) as well. Therefore, the overall time complexity is O(n^2).\n\n\n- Space complexity:\nThe space complexity of this solution is O(n^2) since the "connected" list stores connections for each bomb. Additionally, the "res" list and the "visited" list can each store up to n elements. Therefore, the overall space complexity is O(n^2).\n\n\n# Code\n```\nclass Solution:\n    def maximumDetonation(self, bombs: List[List[int]]) -> int:\n        n=len(bombs)\n        connected=[ [] for i in range(n)]\n\n        for i in range(n):\n            sm=[]\n            for j in range(n):\n                if j!=i:\n                    xi, yi, ri = bombs[i]\n                    xj, yj, _ = bombs[j]\n                    if ri ** 2 >= (xi - xj) ** 2 + (yi - yj) ** 2:\n                        sm.append(j)\n            connected[i]=sm\n        \n        res=[]\n\n        visited=[]\n        def dfs(i:int):\n\n            if i not in visited:\n                visited.append(i)\n                for j in connected[i]:\n                    dfs(j)\n                \n\n        for i in range(n):\n            visited.append(i)\n            for j in connected[i]:\n                dfs(j)\n            res.append(len(visited))\n            visited.clear()\n\n        return max(res)\n        \n \n```
['Python3']