dsa1 min read
Validate Binary Search Tree — Min/Max Bounds DFS
Validate a BST by passing down min and max bounds through DFS, ensuring every node falls strictly within its valid range.
Read →
1575 articles
Validate a BST by passing down min and max bounds through DFS, ensuring every node falls strictly within its valid range.
Find the kth smallest element in a BST using inorder traversal (left-root-right) which visits nodes in sorted order.
Find the LCA of two nodes using post-order DFS: return root when found, propagate upward and split at the ancestor.
Find the LCA in a BST in O(h) by navigating left or right based on whether both nodes are in the same subtree.
Build a binary tree from preorder and inorder traversals by using the preorder root and inorder index to split left/right subtrees.