dsa3 min read
Kth Ancestor of a Tree Node
Find the Kth ancestor of any tree node in O(log k) per query using binary lifting (sparse table DP).
Read →
1575 articles
Find the Kth ancestor of any tree node in O(log k) per query using binary lifting (sparse table DP).
Find the maximum path sum in a binary tree where the path can start and end at any node.
Serialize a binary tree to string and back using BFS level-order or DFS preorder with null markers.
Find the maximum sum of any BST subtree within a binary tree using post-order DFS returning subtree metadata.
Reconstruct a BST from its preorder traversal in O(n) using min-max bounds to place each node.