FastPrepCount Colliding Object Pairs
Problems/Count Colliding Object Pairs

Count Colliding Object Pairs

ZipRecruiter logoZipRecruiter● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter new-grad OA report describes integer centers, repeated centers, coordinate-difference thresholds of two, unordered pairs, and a worked example. We supplied limits and a function signature.

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[][]) → long

Examples

Example 1

centers = [[1,1],[2,2],[0,4]]return = 2

The first and second centers collide, and the second and third centers collide.

Example 2

centers = [[0,0],[0,0]]return = 1

Objects 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

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public long countCollidingPairs(int[][] centers) {
        // Write your code here.
    }

}
Checking account…