EASY 5 POINTER APPROACH || BFS || GRAPH
Intuition\n Describe your first thoughts on how to solve this problem. \nThe algorithm aims to find the maximum number of bombs that can be detonated by choosin
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe algorithm aims to find the maximum number of bombs that can be detonated by choosing only one bomb and triggering its chain reaction.\nBFS is an option to solve this problem as in this case we gotta travel from ont to another bomb and then other to next.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Define a Pair class to represent the (x, y) coordinates and the detonation time of a bomb.\n2. Implement the distance method to calculate the Euclidean distance between two points.\n3. Implement the bfs method to perform breadth-first search (BFS) to find the number of bombs that can be detonated from a given bomb.\n4. In the maximumDetonation method, iterate through each bomb and find the maximum number of detonations by triggering that bomb.\n5. Return the maximum number of detonations.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(N^2 * M)\nPLEASE UPVOTE\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(N)\n# Code\n```\nclass Pair {\n    int x;\n    int y;\n    int time;\n\n    // Constructor to initialize Pair with x, y, and time\n    public Pair(int x, int y, int time) {\n        this.x = x;\n        this.y = y;\n        this.time = time;\n    }\n}\n\nclass Solution {\n    // Helper method to calculate Euclidean distance between two points\n    public double distance(int x1, int y1, int x2, int y2) {\n        int deltaX = x2 - x1;\n        int deltaY = y2 - y1;\n        return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));\n    }\n\n    // Helper method to perform breadth-first search (BFS)\n    public int bfs(int x, int y, int time, int[][] bombs) {\n        int visit[] = new int[bombs.length];\n        int count = 0;\n        Queue<Pair> q = new LinkedList<>();\n        q.add(new Pair(x, y, time));\n\n        while (!q.isEmpty()) {\n            int x1 = q.peek().x;\n            int y1 = q.peek().y;\n            int tym = q.peek().time;\n            q.remove();\n\n            for (int i = 0; i < bombs.length; i++) {\n                if (distance(x1, y1, bombs[i][0], bombs[i][1]) <= tym && visit[i] == 0) {\n                    q.add(new Pair(bombs[i][0], bombs[i][1], bombs[i][2]));\n                    visit[i] = 1;\n                    count++;\n                }\n            }\n        }\n\n        return count;\n    }\n\n    // Main method to find the maximum number of detonations\n    public int maximumDetonation(int[][] bombs) {\n        int n = bombs.length;\n        int ans = 0;\n\n        for (int i = 0; i < n; i++) {\n            ans = Math.max(bfs(bombs[i][0], bombs[i][1], bombs[i][2], bombs), ans);\n        }\n\n        return ans;\n    }\n}\n\n```
['Breadth-First Search', 'Graph', 'Java']