Intuition Explained | Can simple DFS be further optimized?
NOTE: One Bomb can detonate other if and only if the other bomb lies within the area covered by the Bomb.\n\n\n\n\n\n\n\n\nclass Solution {\npublic:\n    double
**NOTE: One Bomb can detonate other if and only if the other bomb lies within the area covered by the Bomb.**\n\n![image](https://assets.leetcode.com/users/images/f3110632-4cc7-4461-917b-489c8bc8b2e9_1639405880.1813633.png)\n\n![image](https://assets.leetcode.com/users/images/094a740b-d884-49af-be24-12b298167b9c_1639407042.709457.png)\n\n![image](https://assets.leetcode.com/users/images/a6f31a54-89db-401b-a12a-8f0326056bf4_1639408158.857844.png)\n\n```\nclass Solution {\npublic:\n    double calcDis(int& x1, int& y1, int& x2, int& y2){\n        \n        long double dis = sqrtl(1LL * (x1-x2)*(x1-x2) + 1LL * (y1-y2)*(y1-y2));\n        \n        return dis;\n    }\n    \n    void dfs(int node, vector<int>& visited,int& thisPathBombs, vector<int> canDetonate[]){\n        \n        visited[node] = 1;\n        thisPathBombs++;\n        \n        for(int i=0;i<canDetonate[node].size();i++){\n            \n            int cnode = canDetonate[node][i];\n            \n            if(visited[cnode] == -1){\n                dfs(cnode,visited,thisPathBombs,canDetonate);\n            }\n        }\n    }\n    \n    int maximumDetonation(vector<vector<int>>& bombs) {\n        \n        int n = bombs.size();\n        \n        vector<int> canDetonate[n];\n        \n        int mxBombs = 0;\n        \n        for(int i=0;i<n;i++){\n            for(int j=i+1;j<n;j++){\n                double dis = calcDis(bombs[i][0],bombs[i][1],bombs[j][0],bombs[j][1]);\n                double d1 = bombs[i][2] * 1.0;\n                double d2 = bombs[j][2] * 1.0;\n                \n                if(dis <= d1){\n                    canDetonate[i].push_back(j);\n                }\n                \n                if(dis <= d2){\n                    canDetonate[j].push_back(i);\n                }\n            }\n        }\n        \n        for(int i=0;i<n;i++) {\n            int thisPathBombs = 0;\n            vector<int> visited(n,-1);\n            dfs(i,visited,thisPathBombs,canDetonate);\n            mxBombs = max(mxBombs, thisPathBombs);\n        }\n        \n        return mxBombs;\n    }\n};\n```\n\n**Here we are running dfs for every node for multiple times.**\n\n![image](https://assets.leetcode.com/users/images/15b06225-569e-4f44-aca3-eb6d5bf70a51_1639408208.1803577.png)\n\n![image](https://assets.leetcode.com/users/images/3598d97d-4c55-4949-b913-7c1bac856242_1639408657.9182005.png)\n\n\n\n\n
['Depth-First Search', 'Graph', 'C++']