Simple C++ code | Both BFS and DFS Approaches
1. DFS Approach : \n\n\n// DFS Approach : ---------->\nclass Solution {\npublic:\n    \n    // find if point p2(x2,y2) will be inside the circle of point p1(x1,
**1. DFS Approach :** \n```\n\n// DFS Approach : ---------->\nclass Solution {\npublic:\n    \n    // find if point p2(x2,y2) will be inside the circle of point p1(x1,y1) \n    bool insideCircle(int x1, int y1, int r, int x2, int y2){\n\t    // euclidean distance\n        int dist = ceil(sqrt( pow(abs(x2-x1),2) + pow(abs(y2-y1),2) ));\n        \n        return (dist <= r);\n    }\n    \n    int dfs(unordered_map<int, vector<int>>&mp, int src, vector<int>&vis)\n    {\n        int count=1;\n        vis[src] = 1;\n        for(auto nbr : mp[src])\n        {\n            if(vis[nbr]==0){\n                \n                vis[nbr]=1;\n                count+=dfs(mp, nbr, vis);\n            }\n                \n        }\n        return count;\n    }\n    \n    // based on number of connected components = number of islands problem\n    int maximumDetonation(vector<vector<int>>& bombs) {\n        \n        // first of all we need to make a undirected (bidirectional) graph\n        int n=bombs.size();\n        unordered_map<int, vector<int>>g;\n        for(int i=0;i<n;i++) // for all center points of circle\n        {\n            int x1 = bombs[i][0];\n            int y1 = bombs[i][1];\n            int r = bombs[i][2];\n            for(int j=0;j<n;j++)\n            {    \n                if(j != i)\n                {\n                    // we need to check it is in the range\n                    if(insideCircle(x1, y1, r, bombs[j][0], bombs[j][1]))\n                    {\n                        g[i].push_back(j);\n                    }\n                }\n            }\n        }\n        \n        int maxbombs=0;\n        for(int i=0;i<n;i++) // har ek point se check karenge ki konse bomb se maximum bombs detonate honge \n        {\n            vector<int>vis(n, 0);\n            int count = dfs(g, i, vis);\n            maxbombs = max(maxbombs,count);\n        }\n        return maxbombs;\n    }\n};\n```\n\n**2. BFS Approach :**\n```\n\n// BFS Approach : -------->\nclass Solution {\npublic:\n    \n    // find if point p2(x2,y2) will be inside the circle of point p1(x1,y1) \n    bool insideCircle(int x1, int y1, int r, int x2, int y2){\n\t    // euclidean distance\n        int dist = ceil(sqrt( pow(abs(x2-x1),2) + pow(abs(y2-y1),2) ));\n        \n        return (dist <= r);\n    }\n    \n    int bfs(unordered_map<int, vector<int>>&mp, int src, vector<int>&vis)\n    {\n        queue<int>q;\n        q.push(src);\n        vis[src] = 1;\n        \n        int count = 0;\n        while(!q.empty())\n        {\n            auto curr = q.front();\n            q.pop();\n            count++;\n            for(auto nbr : mp[curr])\n            {\n                if(vis[nbr] == 0){\n                    \n                    vis[nbr] = 1;\n                    q.push(nbr);\n                }\n            }\n        }\n        return count;\n    }\n    \n    // based on number of connected components = number of islands problem\n    int maximumDetonation(vector<vector<int>>& bombs) {\n        \n        // first of all we need to make a undirected (bidirectional) graph\n        int n=bombs.size();\n        unordered_map<int, vector<int>>g;\n        for(int i=0;i<n;i++) // for all center points of circle\n        {\n            int x1 = bombs[i][0];\n            int y1 = bombs[i][1];\n            int r = bombs[i][2];\n            for(int j=0;j<n;j++)\n            {    \n                if(j != i)\n                {\n                    // we need to check it is in the range\n                    if(insideCircle(x1, y1, r, bombs[j][0], bombs[j][1]))\n                    {\n                        g[i].push_back(j);\n                    }\n                }\n            }\n        }\n        \n        int maxbombs=0;\n        for(int i=0;i<n;i++) // har ek point se check karenge ki konse bomb se maximum bombs detonate honge \n        {\n            vector<int>vis(n, 0);\n            int count = bfs(g, i, vis);\n            maxbombs = max(maxbombs, count);\n        }\n        return maxbombs;\n    }\n};\n```\n**if you like my approach please don\'t forget to hit upvote button ! : )**
['C', 'C++']