spots marked on it, each given as [x, y]. The y axis points up.
An ordered pair of different points (A, B) counts if:
- A is neither to the right of nor below B, that is A.x ≤ B.x and A.y ≥ B.y: A is the upper-left corner and B the lower-right one;
- the rectangle with these corners, border included, contains no other point from spots.
When the two points share an x or a y, the rectangle collapses into a segment and the same rule applies: no other point may lie on that segment.
Return the number of pairs that count.spots=[[0, 4], [2, 2], [4, 0]] → 2
The pairs ([0, 4], [2, 2]) and ([2, 2], [4, 0]) work. The rectangle of ([0, 4], [4, 0]) contains [2, 2], so that pair does not count.
spots=[[1, 1], [3, 5], [5, 3]] → 1
Only ([3, 5], [5, 3]) works. The point [1, 1] is to the left of and below both others, so in no pair can it be either the upper-left or the lower-right corner.
spots=[[2, 6], [2, 3], [2, 1]] → 2
All points share one vertical line. ([2, 6], [2, 3]) and ([2, 3], [2, 1]) work, the rectangle collapses into a segment. [2, 3] lies between [2, 6] and [2, 1].
spots[i] = [x, y], 0 ≤ x, y ≤ 50spots=[[0, 4], [2, 2], [4, 0]]
2
Run checks the first 3 tests in your browser. Submit checks all 108 tests on the server, hidden ones included.