Search
⌘K

Leetcode 655. Print Binary Tree

Given a binary tree, produce an m x n string matrix (m = height+1, n = 2^(height+1)-1) that visually represents the tree by placing the root in the center of the top row and placing each child at column offsets determined by the remaining height (empty cells contain ""). Compute the tree height and assign each node to the appropriate row/column (typically by using midpoints or a recursive/DFS placement) to construct the layout.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.