#3311
Construct 2D Grid Matching Graph Layout
international master · 2000 · lc hard +32 · 29.6% accepted · 80 likes · top 7%
Description
You are given 2D integer array edges describing an undirected graph of n nodes. Reconstruct a 2D grid containing all n nodes exactly once such that two nodes are adjacent in the grid if and only if an edge connects them. Return any valid grid.
Code
1
2
3