Java || 3 ms 100% || Build graph, then DFS from each bomb
This code converts the bomb location and radius to a graph where each bomb is a node in the graph, and the directional edges of the graph are the other bombs th
This code converts the bomb location and radius to a graph where each bomb is a node in the graph, and the directional edges of the graph are the other bombs that the current bomb can reach with its blast radius.  After the graph is build into the variable `links[][]`, a depth-first-search (DFS) is performed starting from each bomb, to determine the total number of bombs to explode from each starting bomb.\n\nThis code is speed optimized.  Most other fast code examples for this leetcode problem, use a List\\<Integer> to contain the edges of the graph.  This code gains some speed by using a byte array terminated with a -1, to contain the edges of the graph.  The primitive data type `byte` array can be faster in execution than the more complex `List` data type.  We can use the byte array because we know the maximum number of edges for any graph node, will be 100, according to the constraints section of the leetcode problem description.  And 100 is a reasonable length to allocate in memory.\n\nIf there are `n` bombs in the passed `bombs[]` array, the graph will consist of a 2-D byte array `byte[][] links = new byte[n][n+1]` where the first index is the node number (index in the `bombs[]` array).  The second index is the index into the edges node numbers, terminatred by a -1 value.\n\nThis code has runtime as fast as 3ms in June 2023, but usually (~70% of submits) has runtime of 4ms. \nIf useful, please upvote.\n```\nclass Solution {\n    public int maximumDetonation(int[][] bombs) {\n        int n = bombs.length;\n        if (n <= 1)  return n;\n        if (n == 2)  return twoBombs(bombs);\n        \n        byte[][] links = new byte[n][n + 1];\n        int[] linksLen = new int[n];\n        for (int b = 0; b < n; b++)\n            buildLinks(links, linksLen, bombs, bombs[b], b);\n        \n        int maxLinks = 0;\n        for (int i = n - 1; i >= 0; i--) {\n            if (linksLen[i] > maxLinks)  maxLinks = linksLen[i];\n            links[i][linksLen[i]] = (byte)-1;\n        }\n        if (maxLinks == 0 || maxLinks == n - 1)  return maxLinks + 1;\n        \n        int maxExplosions = 0;\n        for (int i = n - 1; i >= 0; i--) {\n            maxExplosions = Math.max(maxExplosions, countExplosions(links, new boolean[n], i));\n            if (maxExplosions == n)  break;\n        }\n        return maxExplosions;\n    }\n    \n    \n    private int countExplosions(byte[][] links, boolean[] used, int b) {\n        used[b] = true;\n        int explosions = 1;\n        for (int b1 : links[b]) {\n            if (b1 < 0)  break;\n            if (!used[b1])  explosions += countExplosions(links, used, b1);\n        }\n        return explosions;\n    }\n    \n    \n    private void buildLinks(byte[][] links, int[] linksLen, int[][] bombs, int[] bomb, int b) {\n        int x = bomb[0];\n        int y = bomb[1];\n        long radius = (long)bomb[2] * bomb[2];\n        for (int b1 = links.length - 1; b1 > b; b1--) {\n            int[] bomb1 = bombs[b1];\n            long dist = distance(x, y, bomb1[0], bomb1[1]);\n            if (dist <= radius)  links[b][linksLen[b]++] = (byte)b1;\n            if (dist <= (long)bomb1[2] * bomb1[2])  links[b1][linksLen[b1]++] = (byte)b;\n        }\n    }\n    \n    \n    private long distance(int x1, int y1, int x2, int y2) {\n        return (long)(x1 - x2) * (x1 - x2) + (long)(y1 - y2) * (y1 - y2);\n    }\n    \n    \n    private int twoBombs(int[][] bombs) {\n            int[] b0 = bombs[0];\n            int[] b1 = bombs[1];\n            long dist = distance(b0[0], b0[1], b1[0], b1[1]);\n            if (dist <= (long)b0[2] * b0[2] || dist <= (long)b1[2] * b1[2])  return 2;\n            return 1;\n    }\n}\n```
['Java']