Community

Discussion Board

Anonymous interview experiences, offers and career talk from frontend engineers.

anon_014849

Figma - SWE Fullstack - Phone screen

#figma
0570

Figma · SWE Fullstack, Mid-level (2.5 years)

Rounds

  1. Phone screen, 1 question

Questions asked

  • You are given a list of RectangleNode objects. Each RectangleNode represents a rectangle on a 2D canvas and has properties like x, y, width, and height (or similar coordinates).

Write a function to sort the rectangles in display order, from top-left to bottom-right. The sorting should respect both horizontal and vertical positioning (natural vertical positioning meaning rows of rectangle objects).

Some examples:

A: (x=0, y=0, w=5, h=10)
B: (x=10, y=2, w=5, h=6)
C: (x=20, y=1, w=5, h=8)
Output [A, B, C]

Harder:

A: (0, 0, 10, 6)
B: (12, 3, 10, 12)
C: (25, 1, 10, 5)
D: (0, 20, 10, 5)
Output [A, B, C, D]

Tips

  • The tricky part is deciding when two rectangles are in the same row since their y values aren’t identical. Grouping by vertical overlap first, then sorting each row by x, worked as a mental model.

No replies yet

Markdown supported. 20 more characters needed.