Find the Number of Ways to Place People I

You are given a 2D array points of size n x 2 representing integer coordinates of some points on a 2D plane, where points[i] = [xi, yi].

Count the number of pairs of points (A, B), where:

  • A is on the upper left side of B.
  • There are no other points in the rectangle or line they make, including the border, except for the points A and B.

Return the count.

Example 1
Inputpoints = [[1,1],[2,2],[3,3]]
Output0
There is no way to choose A and B such that A is on the upper left side of B.
Example 2
Inputpoints = [[6,2],[4,4],[2,6]]
Output2
Two adjacent upper-left pairs form empty rectangles, while the pair from points[2] to points[0] is invalid because points[1] lies inside the rectangle.

Constraints

  • 2 <= n <= 50
  • points[i].length == 2
  • 0 <= points[i][0], points[i][1] <= 50
  • All points[i] are distinct.

Asked at 4 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate