Count the number of rectangles formed by a grid of points that are parallel to x and y axis.
Example 1:
points: [
{x: 0, y: 0},
{x: 0, y: 1},
{x: 1, y: 0},
{x: 1, y: 1},
{x: 2, y: 0},
{x: 2, y: 1},
]
• • •
• • •
result: 3
Example 2:
points: [
{x: 0, y: 0},
{x: 0, y: 1},
{x: 1, y: 1},
{x: 2, y: 0},
{x: 2, y: 1},
]
• •
• • •
result: 1