2
* @param {number[][]} bombs5
var maximumDetonation = function (bombs) {6
if (bombs.length <= 1) return bombs.length;10
const checkIfInsideRange = (x, y, center_x, center_y, radius) => {11
return (x - center_x) ** 2 + (y - center_y) ** 2 <= radius ** 2;14
//CREATE ADJACENCY MATRIX15
for (let i = 0; i < bombs.length; i++) {16
for (let j = i + 1; j < bombs.length; j++) {17
if (!adj[i]) adj[i] = [];18
if (!adj[j]) adj[j] = [];19
let bombOne = bombs[i];20
let bombTwo = bombs[j];21
let fir = checkIfInsideRange(28
if (fir) adj[i].push(j);29
let sec = checkIfInsideRange(36
if (sec) adj[j].push(i);40
//DEPTH FIRST SEARCH TO FIND ALL BOMBS TRIGGERED BY NODE41
const dfs = (node, visited) => {44
let childs = adj[node] || [];45
for (let child of childs) {46
if (visited[child]) continue;47
detonated += dfs(child, visited);49
maxSize = Math.max(maxSize, detonated);53
for (let i = 0; i < bombs.length; i++) {