You are given n plates placed on a 2D grid. Plate i is located at coordinate (x[i], y[i]). Each plate has the same magnetic attraction power d.
Two plates are directly connected if the Euclidean distance between them is less than or equal to d. Connectivity is transitive: if a plate is connected directly or indirectly to another plate, collecting one plate collects the entire connected component in the same second.
You may choose one uncollected plate per second. Return the minimum number of seconds required to collect all plates.
n = 4 d = 1 x = [0, 0, 1, 2] y = [0, 1, 0, 2] return = 2
The first three plates form one connected component because adjacent distances are at most 1. The plate at (2,2) is separate, so two seconds are needed.
n = 3 d = 2 x = [0, 3, 6] y = [0, 0, 0] return = 3
Each pair of neighboring plates is distance 3 apart, which is greater than d, so each plate is collected separately.
1 <= n <= 10^50 <= d <= 10^90 <= x[i], y[i] <= 10^9x.length == y.length == n
- Total Palindrome Substring CostOA · Seen Jun 2026
- Earliest Time All Users Are ConnectedPHONE SCREEN · Seen May 2026
- Tournament Rounds by RankPHONE SCREEN · Seen May 2026
- Farthest Seat AssignmentONSITE INTERVIEW · Seen May 2026
- Convex Function MinimizationPHONE SCREEN · Seen May 2026
- Maximal Square AreaONSITE INTERVIEW · Seen May 2026
- First Unique IP Hitting the ServerPHONE SCREEN · Seen May 2026
- Jump Game with Prime-Step RuleOA · Seen May 2026
public int getMinEuclideanTime(int n, int d, int[] x, int[] y) {
// write your code here
}