Tap here to switch tabs
Problem
Submissions

Problem: Find the Number of Ways to Place People I

med
30 min
Try to solve the Find the Number of Ways to Place People I problem.

Statement

You are given a 22D array points of size n $ imes 2$, where points[i] =[xi,yi]= [x_i, y_i] represents the coordinates of the iextthi^{ ext{th}} point on a 22D plane.

A pair of points (A, B) is considered valid if:

  • Point A is to the upper left of point B, meaning A[0] ≤\leq B[0] and A[1] ≥\geq B[1].

  • No other point C lies inside or on the border of the rectangle formed with A as its upper left corner and B as its lower right corner. That is, there is no point C other than A and B such that A[0] ≤\leq C[0] ≤\leq B[0] and B[1] ≤\leq C[1] ≤\leq A[1].

Return the total number of valid pairs (A, B).

Constraints:

  • 2≤2 \leq n ≤50\leq 50, where n == points.length

  • points[i].length =2= 2

  • 0≤0 \leq points[i][0], points[i][1] ≤50\leq 50

  • All elements in points are distinct.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find the Number of Ways to Place People I

med
30 min
Try to solve the Find the Number of Ways to Place People I problem.

Statement

You are given a 22D array points of size n $ imes 2$, where points[i] =[xi,yi]= [x_i, y_i] represents the coordinates of the iextthi^{ ext{th}} point on a 22D plane.

A pair of points (A, B) is considered valid if:

  • Point A is to the upper left of point B, meaning A[0] ≤\leq B[0] and A[1] ≥\geq B[1].

  • No other point C lies inside or on the border of the rectangle formed with A as its upper left corner and B as its lower right corner. That is, there is no point C other than A and B such that A[0] ≤\leq C[0] ≤\leq B[0] and B[1] ≤\leq C[1] ≤\leq A[1].

Return the total number of valid pairs (A, B).

Constraints:

  • 2≤2 \leq n ≤50\leq 50, where n == points.length

  • points[i].length =2= 2

  • 0≤0 \leq points[i][0], points[i][1] ≤50\leq 50

  • All elements in points are distinct.