Count Colliding Object Pairs
Updated
Problem statement
Each row of centers contains integer coordinates [x, y] for one object; several objects may share a center.
Two objects collide exactly when both |x1 - x2| <= 2 and |y1 - y2| <= 2. Return the number of unordered colliding index pairs.
Function
countCollidingPairs(centers: int[][]) → longExamples
Example 1
centers = [[1,1],[2,2],[0,4]]return = 2The first and second centers collide, and the second and third centers collide.
Example 2
centers = [[0,0],[0,0]]return = 1Objects sharing a center collide.
Constraints
0 <= centers.length <= 5000- Every row contains two integers.
More ZipRecruiter Online Assessment questions
- Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
- Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
- Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
- Minimum Changes to Draw a YOA · Seen Oct 2024
- Apply Binary State OperationsOA · Seen Sep 2024
- Simulate Orchard Rot SpreadOA · Seen Sep 2024
- Compare Odd- and Even-Index SumsOA · Seen Sep 2024
- Coordinate Removals with Column GravityOA · Seen Sep 2024
- Lexicographically Smallest End ReversalOA · Seen Sep 2024
- Recursively Expanded Shell Command CountsOA · Seen Sep 2024
Similar questions at other companies
- Coordinate Bounding BoxUpstart · OAUpstart interview questions
- Count Distinct Tags in a Fixed-Radius Circle (Practice Reconstruction)Marshall Wace · OAMarshall Wace interview questions
- Count Overlapping Square PairsRamp · OARamp interview questions
- Starlink Beam PlannerSpaceX · OA · PHONE SCREENSpaceX interview questions
- Maximum Points in a Perimeter-Bounded RectangleAmerican Express · OAAmerican Express interview questions
- Best Meeting PointWalmart · OAWalmart interview questions
- HTTP Request RedirectionAmazon · OA
- Minimum Euclidean Distance Between PointsLuma AI · OALuma AI interview questions
- Closest Point to a LineAdobe · OAAdobe interview questions
- Open Restaurants in a City RangeDoorDash · PHONE SCREENDoorDash interview questions