15% off all plans & roadmaps Use code
See plansConstruct Binary Tree from Preorder and Inorder Traversal
- LeetCode 105
- Medium
- Tree Traversal Patterns (DFS & BFS)
- Recursive Preorder Traversal
Updated
TL;DR: Rebuild a binary tree from its preorder and inorder traversals. Preorder tells you each subtree's root in order, and a hash map of inorder positions tells you where each subtree starts and ends.
Problem
You are given two integer arrays, preorder and inorder. preorder is the preorder traversal of a binary tree, and inorder is the inorder traversal of the same tree. Build the tree and return its root.
Example 1
Input: preorder = [3,9,20,15,7], inorder = [9,3,15,20,7] Output: [3,9,20,null,null,15,7]
Example 2
Input: preorder = [-1], inorder = [-1] Output: [-1]
Constraints
1 <= preorder.length <= 3000inorder.length == preorder.length-3000 <= preorder[i], inorder[i] <= 3000preorderandinorderconsist of unique values.- Every value in
inorderalso appears inpreorder. preorderis guaranteed to be a valid preorder traversal of the tree.inorderis guaranteed to be a valid inorder traversal of the same tree.
Constraints that matter
- n up to 3000 means an O(n^2) solution does about 9 million steps, so it passes. The O(n) answer is still the one to present in an interview.
- All values are unique, so each value maps to exactly one inorder index. This is what makes a hash map lookup valid.
- Both arrays are guaranteed valid for one tree, so you never need to check for inconsistent input or handle missing values.
- The tree can be a straight chain 3000 nodes deep. Recursion depth can reach 3000, which exceeds Python's default limit of 1000, so you must raise it there.
- Values range from -3000 to 3000, so a plain integer index map or a 6001-slot array both work, and there is no overflow risk.
Hints
Hint 1
This is a recursive preorder construction.
Hint 2
Take preorder[0] as the root.
Solution
Intuition
This is a recursive preorder construction. Preorder visits root, then the whole left subtree, then the whole right subtree. So the first unused value in preorder is always the root of the subtree you are building right now.
Picture a long row of numbered seats where each guest's name is on a card, and a separate sign-in sheet lists guests in the order they arrived. The hash map is the table of name-to-seat numbers, and the shared preorder pointer is your finger moving down the sign-in sheet, one guest per node, while the seat numbers split the row into left and right groups.
Preorder alone cannot tell you where the left subtree ends. Inorder can. It lists the left subtree, then the root, then the right subtree. Find the root in inorder and everything to its left is the left subtree, everything to its right is the right subtree.
Take preorder = [3,9,20,15,7] and inorder = [9,3,15,20,7]. The root is 3. In inorder, 3 sits at index 1, so [9] is the left subtree and [15,20,7] is the right subtree. The next preorder value is 9, which builds the left child. Then 20 is the root of the right subtree, and the same split repeats.
Why does this work? Because values are unique, the root's position in inorder is unambiguous. The size of the left part tells you how many preorder values belong to the left subtree. If you build left before right, the shared preorder pointer is exactly where the right subtree's root waits. The only real cost is finding the root in inorder, and a hash map makes that lookup O(1).
Worked example
Input: preorder = [-1], inorder = [-1] Output: [-1] Explanation: The first preorder value, -1, is the root. Its position in inorder is index 0, so nothing lies to its left or right. Both subtrees are empty and the tree is the single node -1.
Approach 1: Brute force: scan and slice
Take preorder[0] as the root. Scan inorder from the left until you hit that value, which gives index k. The left subtree has k nodes, so the next k preorder values and the first k inorder values describe it. The rest describe the right subtree.
Copy those four pieces into new arrays and recurse on each pair. This is the version a beginner writes straight from the definition of the traversals.
Steps
- If
preorderis empty, return null. - Create a node from
preorder[0]. - Scan
inorderlinearly to find the indexkof that value. - Copy
preorder[1..k]andinorder[0..k-1]into new arrays and build the left child from them. - Copy
preorder[k+1..]andinorder[k+1..]into new arrays and build the right child from them. - Return the node.
Dry run
On preorder = [-1], inorder = [-1]:
- The arrays are not empty, so create node -1.
- Scan
inorder. Index 0 holds -1, sok = 0. - Left call gets
preorder[1..0]andinorder[0..-1], both empty. It returns null. - Right call gets
preorder[1..]andinorder[1..], both empty. It returns null. - Return node -1 with no children, which is
[-1].
Complexity
| Time | O(n^2) |
|---|---|
| Space | O(n^2) |
Here n is the number of nodes. Each node triggers one call that scans and copies up to n elements. On a chain-shaped tree the subarray sizes are n, n-1, n-2, and so on, which sums to about n^2 / 2 work. Those copies are all alive at once on the recursion stack for a chain, so extra space is also O(n^2) in the worst case.
PythonTested in our runner
from typing import List, Optional
import sys
sys.setrecursionlimit(10000)
class Solution:
def buildTree(self, preorder: List[int], inorder: List[int]) -> Optional[TreeNode]:
if not preorder:
return None
root = TreeNode(preorder[0])
# linear scan for the root in inorder
k = inorder.index(preorder[0])
# slicing copies the pieces
root.left = self.buildTree(preorder[1:1 + k], inorder[:k])
root.right = self.buildTree(preorder[1 + k:], inorder[k + 1:])
return root
JavaTested in our runner
import java.util.*;
class Solution {
public TreeNode buildTree(int[] preorder, int[] inorder) {
if (preorder.length == 0) {
return null;
}
TreeNode root = new TreeNode(preorder[0]);
int k = 0;
while (inorder[k] != preorder[0]) {
k++;
}
root.left = buildTree(Arrays.copyOfRange(preorder, 1, 1 + k),
Arrays.copyOfRange(inorder, 0, k));
root.right = buildTree(Arrays.copyOfRange(preorder, 1 + k, preorder.length),
Arrays.copyOfRange(inorder, k + 1, inorder.length));
return root;
}
}
C++Tested in our runner
#include <vector>
#include <algorithm>
using namespace std;
class Solution {
public:
TreeNode* buildTree(vector<int>& preorder, vector<int>& inorder) {
if (preorder.empty()) {
return nullptr;
}
TreeNode* root = new TreeNode(preorder[0]);
int k = find(inorder.begin(), inorder.end(), preorder[0]) - inorder.begin();
vector<int> leftPre(preorder.begin() + 1, preorder.begin() + 1 + k);
vector<int> leftIn(inorder.begin(), inorder.begin() + k);
vector<int> rightPre(preorder.begin() + 1 + k, preorder.end());
vector<int> rightIn(inorder.begin() + k + 1, inorder.end());
root->left = buildTree(leftPre, leftIn);
root->right = buildTree(rightPre, rightIn);
return root;
}
};
JavaScriptTested in our runner
/**
* @param {number[]} preorder
* @param {number[]} inorder
* @return {TreeNode}
*/
var buildTree = function(preorder, inorder) {
if (preorder.length === 0) {
return null;
}
const root = new TreeNode(preorder[0]);
const k = inorder.indexOf(preorder[0]);
root.left = buildTree(preorder.slice(1, 1 + k), inorder.slice(0, k));
root.right = buildTree(preorder.slice(1 + k), inorder.slice(k + 1));
return root;
};
GoTested in our runner
func copyPart(a []int) []int {
return append([]int(nil), a...)
}
func buildTree(preorder []int, inorder []int) *TreeNode {
if len(preorder) == 0 {
return nil
}
k := 0
for inorder[k] != preorder[0] {
k++
}
return &TreeNode{
Val: preorder[0],
Left: buildTree(copyPart(preorder[1:1+k]), copyPart(inorder[:k])),
Right: buildTree(copyPart(preorder[1+k:]), copyPart(inorder[k+1:])),
}
}
C#Tested in our runner
public class Solution {
public TreeNode buildTree(int[] preorder, int[] inorder) {
if (preorder.Length == 0) {
return null;
}
TreeNode root = new TreeNode(preorder[0]);
int k = Array.IndexOf(inorder, preorder[0]);
root.left = buildTree(preorder.Skip(1).Take(k).ToArray(),
inorder.Take(k).ToArray());
root.right = buildTree(preorder.Skip(1 + k).ToArray(),
inorder.Skip(k + 1).ToArray());
return root;
}
}
Approach 2: Index ranges with linear scan
What's slow: every call copies four subarrays, which costs time and memory proportional to the subtree size. None of that copying is needed, because each subarray is a contiguous range of the original arrays.
The insight that fixes it: pass indices instead of arrays. A subtree is fully described by the preorder index of its root and an inorder range [lo, hi]. The left subtree has k - lo nodes, so the right subtree's root sits at preorder index preStart + 1 + (k - lo). The scan for the root still costs O(n) per node.
Steps
- Define
build(preStart, lo, hi). Iflo > hi, return null. - Read the root value at
preorder[preStart]. - Scan
inorderfromloupward until you find the value. Call that indexk. - Compute
leftSize = k - lo. - Build the left child with
build(preStart + 1, lo, k - 1). - Build the right child with
build(preStart + 1 + leftSize, k + 1, hi). - Call
build(0, 0, n - 1)to start.
Dry run
On preorder = [-1], inorder = [-1], n = 1:
- Call
build(0, 0, 0). The range is valid, so the root value ispreorder[0] = -1. - Scan from
lo = 0.inorder[0]matches, sok = 0andleftSize = 0. - Left call is
build(1, 0, -1).lo > hi, so it returns null. - Right call is
build(1, 1, 0).lo > hi, so it returns null. - Return node -1, which is
[-1].
Complexity
| Time | O(n^2) |
|---|---|
| Space | O(n) |
Here n is the number of nodes. Each call creates one node and scans at most its own inorder range, so a chain-shaped tree costs about n + (n-1) + ... + 1 comparisons, which is O(n^2). No arrays are copied. The only extra memory is the recursion stack, which is as deep as the tree is tall, so O(n) in the worst case.
PythonTested in our runner
from typing import List, Optional
import sys
sys.setrecursionlimit(10000)
class Solution:
def buildTree(self, preorder: List[int], inorder: List[int]) -> Optional[TreeNode]:
def build(pre_start: int, lo: int, hi: int) -> Optional[TreeNode]:
if lo > hi:
return None
val = preorder[pre_start]
k = lo
while inorder[k] != val: # linear scan inside the range
k += 1
root = TreeNode(val)
root.left = build(pre_start + 1, lo, k - 1)
root.right = build(pre_start + 1 + (k - lo), k + 1, hi)
return root
return build(0, 0, len(inorder) - 1)
JavaTested in our runner
import java.util.*;
class Solution {
public TreeNode buildTree(int[] preorder, int[] inorder) {
return build(preorder, inorder, 0, 0, inorder.length - 1);
}
private TreeNode build(int[] preorder, int[] inorder, int preStart, int lo, int hi) {
if (lo > hi) {
return null;
}
int val = preorder[preStart];
int k = lo;
while (inorder[k] != val) {
k++;
}
TreeNode root = new TreeNode(val);
root.left = build(preorder, inorder, preStart + 1, lo, k - 1);
root.right = build(preorder, inorder, preStart + 1 + (k - lo), k + 1, hi);
return root;
}
}
C++Tested in our runner
#include <vector>
using namespace std;
class Solution {
private:
TreeNode* build(vector<int>& pre, vector<int>& ino, int preStart, int lo, int hi) {
if (lo > hi) {
return nullptr;
}
int val = pre[preStart];
int k = lo;
while (ino[k] != val) {
k++;
}
TreeNode* root = new TreeNode(val);
root->left = build(pre, ino, preStart + 1, lo, k - 1);
root->right = build(pre, ino, preStart + 1 + (k - lo), k + 1, hi);
return root;
}
public:
TreeNode* buildTree(vector<int>& preorder, vector<int>& inorder) {
return build(preorder, inorder, 0, 0, (int)inorder.size() - 1);
}
};
JavaScriptTested in our runner
/**
* @param {number[]} preorder
* @param {number[]} inorder
* @return {TreeNode}
*/
var buildTree = function(preorder, inorder) {
const build = (preStart, lo, hi) => {
if (lo > hi) {
return null;
}
const val = preorder[preStart];
let k = lo;
while (inorder[k] !== val) {
k++;
}
const root = new TreeNode(val);
root.left = build(preStart + 1, lo, k - 1);
root.right = build(preStart + 1 + (k - lo), k + 1, hi);
return root;
};
return build(0, 0, inorder.length - 1);
};
GoTested in our runner
func buildTree(preorder []int, inorder []int) *TreeNode {
var build func(preStart, lo, hi int) *TreeNode
build = func(preStart, lo, hi int) *TreeNode {
if lo > hi {
return nil
}
val := preorder[preStart]
k := lo
for inorder[k] != val {
k++
}
root := &TreeNode{Val: val}
root.Left = build(preStart+1, lo, k-1)
root.Right = build(preStart+1+(k-lo), k+1, hi)
return root
}
return build(0, 0, len(inorder)-1)
}
C#Tested in our runner
public class Solution {
public TreeNode buildTree(int[] preorder, int[] inorder) {
return Build(preorder, inorder, 0, 0, inorder.Length - 1);
}
private TreeNode Build(int[] preorder, int[] inorder, int preStart, int lo, int hi) {
if (lo > hi) {
return null;
}
int val = preorder[preStart];
int k = lo;
while (inorder[k] != val) {
k++;
}
TreeNode root = new TreeNode(val);
root.left = Build(preorder, inorder, preStart + 1, lo, k - 1);
root.right = Build(preorder, inorder, preStart + 1 + (k - lo), k + 1, hi);
return root;
}
}

Solution pattern
Recursive Preorder Traversal
Approach 3: Hash map plus a preorder pointerOptimalRecursive Preorder Traversal
What's slow: the scan that finds the root's inorder index. It repeats for every node and makes a chain-shaped tree cost O(n^2). The values are unique, so that answer never changes and can be computed once.
The insight that fixes it: build a map from value to inorder index before recursing. Then keep one shared pointer into preorder. Each call reads the pointer's value as the root and advances it. Because you build the left subtree before the right one, the pointer always lands on the correct next root, so you never compute preorder offsets.
Steps
- Build a map
indexOffrom each inorder value to its index. - Set a shared preorder pointer
preIdxto 0. - Define
build(lo, hi). Iflo > hi, return null. - Read
preorder[preIdx], advancepreIdx, and create the node. - Look up the node's inorder index
kin the map. - Set
left = build(lo, k - 1)first, thenright = build(k + 1, hi). The order matters. - Return the node. Start with
build(0, n - 1).
Dry run
State on preorder = [-1], inorder = [-1]. The map is {-1: 0} and preIdx starts at 0.
| Step | Call | preIdx before | Action | Result |
|---|---|---|---|---|
| 1 | build(0, 0) | 0 | Range valid. Read preorder[0] = -1, set preIdx = 1. Lookup gives k = 0. | Create node -1 |
| 2 | build(0, -1) | 1 | lo > hi | return null, becomes left |
| 3 | build(1, 0) | 1 | lo > hi | return null, becomes right |
| 4 | return | 1 | Attach both nulls | Return node -1 |
The tree is a single node, which prints as [-1]. Every preorder value was consumed exactly once, since preIdx ended at 1 = n.
Complexity
| Time | O(n) |
|---|---|
| Space | O(n) |
Here n is the number of nodes. Building the map takes n insertions. Each node is created by exactly one non-null call, and each of those does one O(1) map lookup, so there are n real calls and n + 1 calls that return null, which is O(n) in total. The map holds n entries, and the recursion stack is as deep as the tree is tall, which is at most n, so extra space is O(n).
PythonTested in our runner
from typing import List, Optional
import sys
sys.setrecursionlimit(10000)
class Solution:
def buildTree(self, preorder: List[int], inorder: List[int]) -> Optional[TreeNode]:
index_of = {val: i for i, val in enumerate(inorder)}
pre_idx = 0
def build(lo: int, hi: int) -> Optional[TreeNode]:
nonlocal pre_idx
if lo > hi:
return None
val = preorder[pre_idx]
pre_idx += 1
root = TreeNode(val)
k = index_of[val]
# left must be built first: preorder is root, left, right
root.left = build(lo, k - 1)
root.right = build(k + 1, hi)
return root
return build(0, len(inorder) - 1)
JavaTested in our runner
import java.util.*;
class Solution {
private int preIdx;
private Map<Integer, Integer> indexOf;
public TreeNode buildTree(int[] preorder, int[] inorder) {
preIdx = 0;
indexOf = new HashMap<>();
for (int i = 0; i < inorder.length; i++) {
indexOf.put(inorder[i], i);
}
return build(preorder, 0, inorder.length - 1);
}
private TreeNode build(int[] preorder, int lo, int hi) {
if (lo > hi) {
return null;
}
int val = preorder[preIdx++];
TreeNode root = new TreeNode(val);
int k = indexOf.get(val);
root.left = build(preorder, lo, k - 1);
root.right = build(preorder, k + 1, hi);
return root;
}
}
C++Tested in our runner
#include <vector>
#include <unordered_map>
using namespace std;
class Solution {
private:
unordered_map<int, int> indexOf;
int preIdx = 0;
TreeNode* build(vector<int>& preorder, int lo, int hi) {
if (lo > hi) {
return nullptr;
}
int val = preorder[preIdx++];
TreeNode* root = new TreeNode(val);
int k = indexOf[val];
root->left = build(preorder, lo, k - 1);
root->right = build(preorder, k + 1, hi);
return root;
}
public:
TreeNode* buildTree(vector<int>& preorder, vector<int>& inorder) {
preIdx = 0;
indexOf.clear();
for (int i = 0; i < (int)inorder.size(); i++) {
indexOf[inorder[i]] = i;
}
return build(preorder, 0, (int)inorder.size() - 1);
}
};
JavaScriptTested in our runner
/**
* @param {number[]} preorder
* @param {number[]} inorder
* @return {TreeNode}
*/
var buildTree = function(preorder, inorder) {
const indexOf = new Map();
for (let i = 0; i < inorder.length; i++) {
indexOf.set(inorder[i], i);
}
let preIdx = 0;
const build = (lo, hi) => {
if (lo > hi) {
return null;
}
const val = preorder[preIdx++];
const root = new TreeNode(val);
const k = indexOf.get(val);
root.left = build(lo, k - 1);
root.right = build(k + 1, hi);
return root;
};
return build(0, inorder.length - 1);
};
GoTested in our runner
func buildTree(preorder []int, inorder []int) *TreeNode {
indexOf := make(map[int]int, len(inorder))
for i, v := range inorder {
indexOf[v] = i
}
preIdx := 0
var build func(lo, hi int) *TreeNode
build = func(lo, hi int) *TreeNode {
if lo > hi {
return nil
}
val := preorder[preIdx]
preIdx++
root := &TreeNode{Val: val}
k := indexOf[val]
root.Left = build(lo, k-1)
root.Right = build(k+1, hi)
return root
}
return build(0, len(inorder)-1)
}
C#Tested in our runner
public class Solution {
private Dictionary<int, int> indexOf;
private int preIdx;
public TreeNode buildTree(int[] preorder, int[] inorder) {
indexOf = new Dictionary<int, int>();
for (int i = 0; i < inorder.Length; i++) {
indexOf[inorder[i]] = i;
}
preIdx = 0;
return Build(preorder, 0, inorder.Length - 1);
}
private TreeNode Build(int[] preorder, int lo, int hi) {
if (lo > hi) {
return null;
}
int val = preorder[preIdx++];
TreeNode root = new TreeNode(val);
int k = indexOf[val];
root.left = Build(preorder, lo, k - 1);
root.right = Build(preorder, k + 1, hi);
return root;
}
}
Common mistakes
- Building the right subtree before the left:
root.right = build(k + 1, hi)placed aboveroot.left = build(lo, k - 1). Preorder consumes the left subtree first, so the shared pointer then lands on the wrong values. Always assign left first. - Slicing arrays in every call, such as
preorder[1:1+k]orArrays.copyOfRange. Each copy costs O(n), so the whole build becomes O(n^2) time and memory. Passloandhiindices instead. - Using the inorder index to read preorder, as in
preorder[k]for the root. The two arrays are aligned only through subtree sizes. Read the root from a pointer that advances once per created node. - Checking the base case after reading
preorder[preIdx]. When the range is empty, the pointer may already be past the end, so you get an out-of-range error. Testlo > hifirst and return before touchingpreorder. - Forgetting to raise Python's recursion limit. A chain-shaped tree with 3000 nodes recurses 3000 deep and the default limit of 1000 raises
RecursionError. Callsys.setrecursionlimit(10000)before recursing. - Resetting state incorrectly in C++ or Java fields. If
preIdxor the map is not reset at the start ofbuildTree, a second call on the sameSolutionobject reuses stale values. Reinitialize both at the top of the method.
Edge cases
- A single node,
preorder = [-1],inorder = [-1]: return a node with value -1 and both children null. - Left-skewed chain,
preorder = [3,2,1],inorder = [1,2,3]: every right range is empty, and the recursion goes 3 deep. - Right-skewed chain,
preorder = [1,2,3],inorder = [1,2,3]: every left range is empty, and each node has only a right child. - Maximum size of 3000 nodes in a chain: recursion depth reaches 3000, so Python needs a higher recursion limit.
- Negative values and zero, such as
preorder = [0,-3,3],inorder = [-3,0,3]: the map keys are plain integers, so negatives need no special handling and the root 0 gets a left child -3 and a right child 3. - A perfectly balanced tree such as
preorder = [3,9,20,15,7],inorder = [9,3,15,20,7]: the root 3 has left child 9 and right child 20, and 20 has children 15 and 7.
Follow-ups interviewers ask
- Can you do it without recursion?
- Yes. Keep a stack of nodes and two pointers, one into preorder and one into inorder. Push each new preorder value as the left child of the stack top until the top equals the current inorder value. Then pop while the top still matches inorder, advancing the inorder pointer, and attach the next preorder value as the right child of the last popped node. This is O(n) time and O(h) stack space with no hash map, and it avoids deep recursion.
- Can you build the tree from inorder and postorder instead?
- Yes. Postorder ends with the root, so you read the postorder array from the right. Each root is followed by the right subtree and then the left one when read backward. So you build the right child before the left child, and the rest of the algorithm is identical.
- Can preorder and inorder have repeated values?
- Not without extra information. With duplicates, the root's inorder position is ambiguous, so several different trees can produce the same pair of traversals. The unique-values constraint is what makes the map lookup and the answer well defined. With duplicates you would need extra rules or you could only count the possible trees.
Construct Binary Tree from Preorder and Inorder Traversal FAQ
What is the time complexity of Construct Binary Tree from Preorder and Inorder Traversal?
The hash map version runs in O(n) time, where n is the number of nodes. Building the map costs n insertions, and each node is created once with one O(1) lookup. The scan-based versions take O(n^2) in the worst case, which happens on a chain-shaped tree.
Why use a hash map for Construct Binary Tree from Preorder and Inorder Traversal?
Every node needs the inorder index of its value to split the left and right subtrees. Values are unique, so that index never changes, and you can store it once. The map turns a repeated O(n) scan into an O(1) lookup, which drops the total from O(n^2) to O(n).
Can Construct Binary Tree from Preorder and Inorder Traversal be solved in O(1) extra space?
No, not counting the output tree. The recursive solution needs a stack as deep as the tree and a map of n entries. You can drop the map by scanning, but that costs O(n^2) time. Even an iterative version needs an explicit stack of up to O(h) nodes, so true O(1) is not achievable in a simple way.
Why does the order of the two recursive calls matter?
The shared preorder pointer moves forward one value per node created. Preorder lists the whole left subtree before the right subtree. So the left call must run first and consume exactly the left subtree's values. If you swap the calls, the right subtree reads values that belong to the left.
Why does a Python solution to LeetCode 105 need a higher recursion limit?
The input can describe a chain of 3000 nodes, so recursion goes 3000 calls deep. Python's default limit is 1000, which raises a RecursionError on such inputs. Setting sys.setrecursionlimit(10000) fixes it. Java, C++, Go and C# handle this depth with their default stacks.
Do I need both traversals to rebuild the tree?
Yes. Preorder alone cannot tell you where the left subtree ends, so many trees share one preorder. Inorder alone cannot tell you which value is the root. Together they fix the root and the split, so the tree is unique when values are distinct.
Asked at
See which companies ask this — Pro
Related problems
- Count Good Nodes in Binary Tree · same technique: Recursive Preorder Traversal
- Insert into a Binary Search Tree · same technique: Recursive Preorder Traversal
- Construct Quad Tree · same technique: Recursive Preorder Traversal
- Flatten Binary Tree to Linked List · same technique: Recursive Preorder Traversal
- Smallest String Starting From Leaf · same technique: Recursive Preorder Traversal
- Binary Tree Maximum Path Sum · next harder, same pattern
- Validate Binary Search Tree · same pattern: Tree Traversal Patterns (DFS & BFS)
- Binary Tree Level Order Traversal · same pattern: Tree Traversal Patterns (DFS & BFS)
- Binary Tree Right Side View · same pattern: Tree Traversal Patterns (DFS & BFS)
- Lowest Common Ancestor of a Binary Search Tree · same pattern: Tree Traversal Patterns (DFS & BFS)