Ruby solution with BFS (100%/100%)
Intuition\nFor each bomb, find the bombs it immediately causes to explode, then BFS to find how many it explodes in total.\n\n# Approach\n1. Create a hash of bo
# Intuition\nFor each bomb, find the bombs it immediately causes to explode, then BFS to find how many it explodes in total.\n\n# Approach\n1. Create a hash of bombs that each bomb will directly explode (each key is an index, each value is an array of indices of other bombs).\n2. Iterate through every pair of bombs.  For each pair:\n    - Use the distance formula to check if the first bomb explodes the other.  If so, add it to the hash.\n    - Check if the second bomb explodes the first bomb, and add it to the *second* bomb\'s array if so.\n3. Initialize the maximum to be zero (in case there are no bombs).\n4. BFS from each bomb to see all other bombs it explodes:\n    - Create a set of bombs that have exploded.\n    - Create a queue with the first bomb.\n    - For each bomb in the queue, check if it explodes any bombs that haven\'t exploded yet.  If so, add those bombs to the checked set and the queue.\n    - Once queue is empty, compare the size of the checked (exploded) bombs to max, and take whichever is bigger.\n5. Return max.\n\n# Complexity\n- Time complexity:\n$$O(n^2)$$\n\n- Space complexity:\n$$O(n^2)$$\n\n# Code\n```\ndef maximum_detonation(bombs)\n    chain = Hash.new { |h,k| h[k] = [] }\n\n    bombs.each_with_index do |bomb,i|\n        bombs.each_with_index do |bomb2,j|\n            if i > j\n                a,b,c = bomb\n                d,e,f = bomb2\n\n                chain[i] << j if (a-d)**2 + (b-e)**2 <= c**2\n                chain[j] << i if (a-d)**2 + (b-e)**2 <= f**2\n            end\n        end\n    end\n\n    max = 0\n\n    (0...bombs.length).each do |i|\n        checked = Set[i]\n        queue = checked.to_a\n\n        until queue.empty?\n            bomb = queue.shift\n            connections = chain[bomb]\n            connections.each do |connection|\n                queue << connection unless checked.include?(connection)\n                checked.add(connection)\n            end\n        end\n\n        max = checked.size if checked.size > max\n    end\n\n    max\nend\n```
['Ruby']