Skip to content

Latest commit

 

History

History

count-rectangles

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

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

Youtube