Given a list of 2d integer coordinates,
look for squares whose four corners occur in the input.
Return the upper left corner and the side length of all
such unique squares, in any order.
input:
points = [
{"x": 2, "y": 4}, # top-left
{"x": 4, "y": 4}, # top-right
{"x": 2, "y": 2}, # bottom-left
{"x": 4, "y": 2}, # bottom-right
{"x": 5, "y": 5}, # extra random point
{"x": 0, "y": 0} # extra random point
]
Output: [{'x': 2, 'y': 4, 'side': 2}]I solved with O(n x m) and was asked for optimization but wasn't able to come up with anything better.
Comments (3)


