C++  Easy to understand DFS solution
Intuition\nWe select a bomb Bi to detonate first and then look for other bombs in range (let\'s say it is Bj), it form\'s a graph i.e, there exist a directed ed
# Intuition\nWe select a bomb Bi to detonate first and then look for other bombs in range (let\'s say it is Bj), it form\'s a graph i.e, there exist a directed edge between bomb Bi and Bj and so on. Thus, DFS can be applied on each and every bomb in our array and max result can be checked after completion of each DFS.\n\n# Approach\n1. Declare ans as -1 or INT_MIN (any negative value).\n2. Select each bomb in the array as the first bomb to detonate.\n3. Create a hash table to keep record of already detonated bomb so that we don\'t count them more than once in our DFS (Similar to avoiding cycle in a graph).\n4. Call DFS.\n5. Go through each bomb that has not yet detonated.\n6. If the bomb Bj is in range i.e the distance between the bombs Bi and Bj in less than ri(radius of Bi) than Bj will explode so mark it visited and apply DFS on it and add the bombs that will detonate because of Bj to Bi. \n7. Return the number of bombs that can explode because of the detonation of ith bomb *(Note that curr_ans=1 because if a bomb is detonated than atleast it will explode even if no other bomb is in range).*\n8. Compare it with the earlier answer .\n# Complexity\n- Time complexity:\nO(n^3)\n\n- Space complexity:\nO(n)\n\n# Code\n```\nclass Solution {\n    long long distance(long long x1,long long y1,long long x2,long long y2){\n        return (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1);\n    }\n    int dfs(vector<vector<int>>&bombs,int i,map<int,bool>&visited){\n        int curr_ans=1;\n        \n        for(int j=0;j<bombs.size();j++){\n            if(j==i or visited[j]==true)continue;\n            long long dis=distance(bombs[i][0],bombs[i][1],bombs[j][0],bombs[j][1]);\n            if(dis<=bombs[i][2]*1LL*bombs[i][2]){\n                visited[j]=true;\n                curr_ans+=dfs(bombs,j,visited);\n            }\n        }\n        return curr_ans;\n    }\npublic:\n    int maximumDetonation(vector<vector<int>>& bombs) {\n        int ans=INT_MIN;\n        for(int i=0;i<bombs.size();i++){\n            map<int,bool>visited; //use unordered_map or vector for better time\n            visited[i]=true;\n            ans=max(ans,dfs(bombs,i,visited));\n        }\n        return ans;\n    }\n};\n```
['Graph', 'C++']