Minimum Euclidean Plate Collection Time
Updated
Problem statement
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.
Function
getMinEuclideanTime(n: int, d: int, x: int[], y: int[]) → intExamples
Example 1
n = 4d = 1x = [0, 0, 1, 2]y = [0, 1, 0, 2]return = 2The 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.
Example 2
n = 3d = 2x = [0, 3, 6]y = [0, 0, 0]return = 3Each pair of neighboring plates is distance 3 apart, which is greater than d, so each plate is collected separately.
Constraints
- Constraints:
1 <= n <= 10000 <= d <= 100000 <= x[i], y[i] <= 10000x.length == y.length == n
More Uber Online Assessment questions
- Count Palindromic Ancestor PathsOA · Seen Aug 2026
- Jump Game with Prime-3 StepsOA · Seen Aug 2026
- Last Truck to Leave the LaneOA · Seen Jul 2026
- Chain of CommandOA · Seen Jul 2026
- Total Palindrome Substring CostOA · Seen Jun 2026
- Jump Game with Prime-Step RuleOA · Seen May 2026
- Pipeline Throughput Maximization Under BudgetOA · Seen May 2026
- Balanced Prefix Sets in a PermutationOA · Seen Apr 2026
- Minimum Edge Reversals to Root a TreeOA · Seen Apr 2026
- Maximum Riders in CarOA · Seen Apr 2026