dsa2 min read
Find Duplicate Subtrees
Find all duplicate subtrees by serializing each subtree and using a hash map to detect duplicates.
Read →
webcoderspeed.com
1276 articles
Find all duplicate subtrees by serializing each subtree and using a hash map to detect duplicates.
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.