dsa2 min read
Unique Binary Search Trees II
Generate all structurally unique BSTs with values 1 to n using divide and conquer with memoization.
Read →
1575 articles
Generate all structurally unique BSTs with values 1 to n using divide and conquer with memoization.
Trim a BST so all values lie within [low, high] by recursively pruning out-of-range subtrees.
Serialize a BST to a compact preorder string and reconstruct it using the min-max BST property.
Group tree nodes by vertical column then row, sorting by value within same position using BFS with coordinates.
Find path directions between two tree nodes by finding LCA then building paths from LCA to each target.