Count of rectangles that can be formed with stream of points

Revision en2, by abhi55, 2021-07-13 22:04:28

This question was asked in an online screening test. Any clue how to solve it with Online Approach better than O(N^3)?

My Approach:

Maintain two maps of Map<X, Set> and Map<Y, Set> and for each point find horizontal and vertical points and for every triplet check 4th point exist or not.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English abhi55 2021-07-13 22:04:28 187
en1 English abhi55 2021-07-13 22:01:12 292 Initial revision (published)