Back to problems

Sort Documents on a 2D Plane

Algorithm · Figma · Medium

Problem You are given a collection of documents placed on a 2D plane. Each document is described by its x-coordinate and its width. Return the documents sorted from left to right. Follow-up 1 Documents are now organized into rows. Sort the documents top-to-bottom by row first, and then left-to-right within each row. Follow-up 2 Documents can now be nested: a parent document can contain child documents. Produce an ordering that respects this containment. A parent must appear…

Checking your access…