Java | DFS | Beats > 70% | Clean code
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\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```\nclass Solution {\n  private List<Integer>[] adj;\n  private boolean[] seen;\n\n  private int dfs(int node) {\n    seen[node] = true;\n    var cnt = 1;\n    \n    for (var neighbor : adj[node])\n      if (!seen[neighbor])\n        cnt += dfs(neighbor);\n    \n    return cnt;\n  }\n\n  public int maximumDetonation(int[][] bombs) {\n    var max = 0;\n    var n = bombs.length;\n    seen = new boolean[n];\n    adj = new ArrayList[n];\n\n    for (var i=0; i<n; i++)\n      adj[i] = new ArrayList<>();\n\n    for (var i=0; i<n; i++) {\n      for (var j=0; j<n; j++) {\n        if (i == j) continue;\n\n        var a = bombs[i];\n        var b = bombs[j];\n\n        if (Math.pow(a[0] - b[0], 2) + Math.pow(a[1] - b[1], 2) <= Math.pow(a[2], 2))\n          adj[i].add(j);\n      }\n    }\n    for (var i=0; i<n; i++) {\n      Arrays.fill(seen, false);\n      max = Math.max(max, dfs(i));\n    }\n    return max;\n  }\n}\n```\nIf you like my solution, please upvote it!
['Math', 'Depth-First Search', 'Graph', 'Geometry', 'Java']