Facebook phone interview. [Reject]

Was underprepared with just under 2 (irregular) months on leet.
Given a list of cartesian co-ordinates find if any 4 of them make a rectangle.
I came up with a brute force approach:

  1. Group points in combinations of 4.
  2. calculate all possible distances between them.
  3. The distances should only have 3 distinct values - 2 sides & diagonal.
    (2 distinct values would make it a square).

Felt quite clever that I came up with this, but did not have enough time to code up the solution.
I feel quite inspired by this, despite the rejection.
Would love to hear of any of you leeters have a better solution.

Comments (5)