Homepage
Open in app
Sign in
Get started
Array
Backtracking / DP / Greedy
Heap / Linked List
Two Pointers / Binary Search
Tree / Graph
Backend
Tree / Graph
[Leetcode] Validate Binary Search Tree
[Leetcode] Validate Binary Search Tree
Many tree questions can be addressed using recursive (helper) functions. To keep the variation for specific variables along the recursion…
PHIL
Feb 6, 2022
[Leetcode] Construct Binary Tree from Preorder and Inorder Traversal
[Leetcode] Construct Binary Tree from Preorder and Inorder Traversal
The preorder and inorder list share some sequence pattern, suggesting which index/element to be constructed as root’s left and right.
PHIL
Feb 9, 2022
[Leetcode] Design Add and Search Words Data Structure
A divergence of trie. While some solution uses Trienode, it may be too slow and a simple dictionary could work.
PHIL
Feb 11, 2022
[Leetcode] Number of Islands
Classic combination of matrix and DFS / BFS. Use a matrix “visited” of same size to flag visited nodes and stop duplicate path. Values or…
PHIL
Feb 16, 2022
[Leetcode] Course Schedule
The condition of question leads to Cycle detection for directed graph. DFS would help.
PHIL
Feb 24, 2022
[Leetcode] Subtree of Another Tree
[Leetcode] Subtree of Another Tree
Extension of same tree. Practice template of DFS in tree.
PHIL
Feb 26, 2022
[Leetcode] Implement Trie (Prefix Tree)
Practice template of DFS in tree. The interesting difference is the trie permits multiple decendants rather than two in same level.
PHIL
Feb 27, 2022
[Leetcode] Kth Smallest Element in a BST
[Leetcode] Kth Smallest Element in a BST
Simpler than first impression. Inorder traversal makes a sorted array in BST. Stop as the k element is done.
PHIL
Mar 2, 2022
[Leetcode] Binary Tree Level Order Traversal
[Leetcode] Binary Tree Level Order Traversal
A must-practiced question of BFS.
PHIL
Mar 5, 2022
[Leetcode] Pacific Atlantic Water Flow
[Leetcode] Pacific Atlantic Water Flow
A more complicated version of Number of Islands.
PHIL
Mar 20, 2022
About Coding Memo
Latest Stories
Archive
About Medium
Terms
Privacy
Teams