4
u -> v means, v is in the range of u5
check from which node maximum nodes can be reached and return the number of nodes reached7
public int maximumDetonation(int[][] bombs) {8
Map<Integer, List<Integer>> graph = new HashMap<>();11
for (int i = 0; i < n; i++) {12
graph.put(i, new ArrayList<>());13
for (int j = 0; j < n; j++) {15
if (inRange(bombs[i], bombs[j])) graph.get(i).add(j);20
for (int i = 0; i < n; i++) {21
max = Math.max(max, dfs(i, graph, new HashSet<>()));26
private boolean inRange(int[] u, int[] v) {27
// (x-a)^2 + (y-b)^2 = R^2 -> point (a, b) is at border28
// (x-a)^2 + (y-b)^2 < R^2 -> point (a, b) is inside the circle29
// (x-a)^2 + (y-b)^2 > R^2 -> point (a, b) is outside the circle30
return Math.pow(u[0] - v[0], 2) + Math.pow(u[1] - v[1], 2) <= Math.pow(u[2], 2);33
private int dfs(int node, Map<Integer, List<Integer>> graph, Set<Integer> visited) {34
if (visited.contains(node)) return 0;37
for (int neigh : graph.get(node)) {38
res += dfs(neigh, graph, visited);