Count Overlapping 2x2 Squares

Given the integer center coordinates (x, y) of n axis-aligned 2x2 squares, count the number of pairs of squares that overlap.

Rules:

  • Two squares overlap iff |x1-x2| ≤ 2 and |y1-y2| ≤ 2 (touchin...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: