230. Kth Smallest Element in a BST
A BST's inorder traversal visits nodes in ascending order. The kth node visited during inorder traversal is the kth smallest element. The recursive solution is concise and easy to understand. The iterative solution uses a stack to simulate recursion and is the standard interview approach.
LeetCode 98: Validate Binary Search Tree (Python)
Comparing a node with only its parent is not sufficient. Every node must satisfy constraints inherited from all its ancestors. Passing a valid (lower, upper) range during DFS elegantly enforces the BST rules. This is the standard interview solution and is both simple and optimal.
1448. Count Good Nodes in Binary Tree (LeetCode)
This is an excellent example of a DFS problem where the trick is not the traversal itself, but what information you carry along the path. By passing the maximum value seen so far, each node can determine independently whether it is "good," resulting in a simple and efficient O(n) solution.
199. Binary Tree Right Side View (LeetCode) – BFS Explained
Whenever a binary tree problem asks for something "per level", BFS should be one of your first thoughts. For the right side view: Traverse level by level. The last node of every level is visible from the right. Record it and continue.
LeetCode 235: Lowest Common Ancestor of a Binary Search Tree
Binary Search Trees (BSTs) are special because they allow us to make decisions without exploring every node. This problem is a great example of taking advantage of that property to find the Lowest Common Ancestor (LCA) in O(h)time instead of searching the entire tree.
572. Subtree of Another Tree – Explanation
A brute-force approach would compare subRoot against every node, which is exactly what this recursive solution does. Since each comparison uses the optimal Same Tree algorithm, this is the standard interview solution and is accepted by virtually every interviewer.
LeetCode 110: Balanced Binary Tree – Three DFS Solutions Explained
Whenever a tree problem asks you to determine something about a node based on information from its children, think post-order DFS. For this problem, every node needs: left subtree height, right subtree height, whether both subtrees are already balanced
Leetcode 104 : Maximum Depth of Binary Tree — Recursive DFS, BFS, and Iterative DFS
With recursive DFS, the answer for each node is:1 + the greater depth of its two subtrees With BFS, the answer is the number of levels processed. With iterative DFS, each node is stored together with its current depth.
226. Invert Binary Tree – Three Ways to Solve It (Recursive, DFS, and BFS)
Binary Tree problems are a staple in coding interviews, and Invert Binary Tree is one of the most famous ones. Despite its simplicity, this problem is an excellent exercise for understanding tree traversal and the differences between recursive DFS, iterative DFS, and BFS.
