Back to problems

Count Squares Formed by Segments

Algorithm · Waymo · Hard

You are given two separate lists of axis-aligned line segments with integer endpoints. The list vertical contains only segments parallel to the y-axis, meaning each endpoint pair has the same x-coordinate. The list horizontal contains only segments parallel to the x-axis, meaning each endpoint pair has the same y-coordinate. Implement the following function: Return the number of distinct axis-aligned squares whose four sides are fully covered by the union of the supplied…

Checking your access…