Loading problem...
An operations analytics team stores geometric checkpoints as labeled 2D coordinates.
Table: points
A pair of points can represent opposite corners of an axis-aligned rectangle when:
For every valid pair, compute:
Task: Return every valid opposite-corner pair and its rectangle area.
Output requirements:
Supported submission environments:
points:
| id | x_value | y_value |
|----|---------|---------|
| 1 | 2 | 7 |
| 2 | 4 | 8 |
| 3 | 2 | 10 |[
{"p1":2,"p2":3,"area":4},
{"p1":1,"p2":2,"area":2}
]Pair (1,3) is excluded because x coordinates are equal, so area is zero. The remaining valid pairs are sorted by area descending.
points:
| id | x_value | y_value |
|----|---------|---------|
| 10 | 0 | 0 |
| 11 | 2 | 1 |
| 12 | 1 | 3 |
| 13 | 3 | 2 |[
{"p1":10,"p2":13,"area":6},
{"p1":10,"p2":12,"area":3},
{"p1":10,"p2":11,"area":2},
{"p1":11,"p2":12,"area":2},
{"p1":12,"p2":13,"area":2},
{"p1":11,"p2":13,"area":1}
]Several pairs tie on area = 2, so tie-breaking uses p1 ascending, then p2 ascending.
points:
| id | x_value | y_value |
|----|---------|---------|
| 21 | 5 | 1 |
| 22 | 5 | 4 |
| 23 | 5 | 9 |
| 24 | 5 | 20 |[]All points share the same x coordinate, so every pair has zero rectangle width and is excluded.
Constraints