Canvas Reading Order

Asked at Figma· Screen

Reported by the problem's creator, not verified

Import another question

You design a CanvasReader class that orders canvas elements the way a screen reader would read them. An element is [id, x, y]: id is its unique identifier, x grows to the right and y grows downward. Each test creates one CanvasReader() and calls its methods several times; every call's return value is recorded in order.

Examples

  1. Example 1

    Input: init = [], operations = [["reading_order",[[[1,50,10],[2,10,10],[3,30,0],[4,0,20]]]],["reading_order",[[]]],["reading_order",[[[7,5,5]]]]]

    Output: [[3,2,1,4],[],[7]]

    Explanation: Element 3 has the smallest y (0) and comes first. Elements 1 and 2 share y = 10, so 2 (smaller x) precedes 1, and 4 has the largest y. The empty call returns [], and the single element returns [7].

Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.
Import a question

Code

Loading editor…

Ln 1, Col 1

Start an attempt to use Coach.