🔥🔥Easy To Understand Solution- C++ With Comments🔥🔥
Intuition\nIn the given 2D vector bombs they are giving a co-ordinate with radius.\nSo intuition is to build an adjacency list in which we can see how \nmany mo
# Intuition\nIn the given 2D vector bombs they are giving a co-ordinate with radius.\nSo intuition is to build an adjacency list in which we can see how \nmany more co-ordinates we can access at a particular index.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nSo the Approach is to see from every index at i using radius that how many more indexes we can reach to maximize our answer.By the help of distance formula x1 is i and x2 is j, DistanceBetweenx1ANDx2 = ( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) and radius.\nif DistanceBetweenx1ANDx2 <= radius (at i) then we can reach other wise we can\'t.\n\n\n\nAs comments has give follow that to undestand the complete solution.\n\nFEEL FREE TO DISCUSS YOUR IDEAS WE AS A COMMUNITY LETS HELP EACH OTHER.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(n*n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n- In Worst Case:O(n*n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    typedef long long ll;\nprivate:\n    void dfs(int node,vector<int>*adj,vector<bool>&vis,int &ANS){\n        vis[node]=true;\n        //Increasing the number of bombs detonated\n        ANS+=1;\n        //Going through all the adjacent/neighbours nodes\n        for(auto &adjNode:adj[node]){\n            if(!vis[adjNode]){\n                dfs(adjNode,adj,vis,ANS);\n            }\n        }\n    }\npublic:\n    int maximumDetonation(vector<vector<int>>& bombs) {\n        \n        int n=bombs.size();\n        vector<int>adj[n];\n\n        for(int i=0;i<n;i++){\n            // this is the value of first point in graph and radius\n            ll x1=(ll)bombs[i][0];\n            ll y1=(ll)bombs[i][1];\n            ll r1=(ll)bombs[i][2];\n            for(int j=0;j<n;j++){\n                // this is the value of second point in graph and radius\n                ll x2=(ll)bombs[j][0];\n                ll y2=(ll)bombs[j][1];\n                ll r2=(ll)bombs[j][2];\n                //Here we are finding the distance from point (x1,y1) to (x2,y2)\n                ll DistanceBetweenx1ANDx2 = ( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );\n                //Checking whether the distance is less than or equal to r1 as up to r1 only our circle          \n                //can stetch\n                if(DistanceBetweenx1ANDx2 <= r1*r1){\n                    // Here we can state that from index i to index j we can reach by using radius r1\n                    adj[i].push_back(j);\n                }\n            }\n        }\n\n        int ans=0;\n        for(int i=0;i<n;i++){\n            vector<bool>vis(n,false);\n            if(!vis[i]){\n                //Here initially we are keeping ANS=0 for every node to see that maximum number of bombs \n                //can be detonated  from node i\n                int ANS=0;\n                dfs(i,adj,vis,ANS);\n                ans=max(ans,ANS);\n            }\n        }\n\n        return ans;\n    }\n};\n```
['Depth-First Search', 'Graph', 'Recursion', 'C++']