Binary-Search-Tree
LeetCode 703: Kth Largest Element in a Stream
·1 min
LeetCode
Easy
Tree
Design
Binary-Search-Tree
Heap-Priority-Queue
LeetCode 703 note: keep a min-heap of size k; its top is the k-th largest
LeetCode 700: Search in a Binary Search Tree
·1 min
LeetCode
Easy
Tree
Binary-Search-Tree
Binary-Tree
LeetCode 700 note: go left when the node is larger, right when smaller, and return the node when found
LeetCode 530: Minimum Absolute Difference in BST
·1 min
LeetCode
Easy
Tree
Depth-First-Search
Breadth-First-Search
Binary-Search-Tree
LeetCode 530 note: a BST’s in-order is ascending, so the minimum difference is between in-order neighbors; remember the previous value and compare
LeetCode 501: Find Mode in Binary Search Tree
·2 mins
LeetCode
Easy
Tree
Depth-First-Search
Binary-Search-Tree
Binary-Tree
LeetCode 501 note: a BST’s in-order is sorted, so equal values are contiguous; count the current run during in-order, resetting the answer on a new maximum and appending on a tie
LeetCode 235: Lowest Common Ancestor of a Binary Search Tree
·2 mins
LeetCode
Medium
Tree
Depth-First-Search
Binary-Search-Tree
Binary-Tree
LeetCode 235 note: go left when both p and q are smaller, right when both are larger; otherwise (split, or one is the node itself) this node is the LCA
LeetCode 108: Convert Sorted Array to Binary Search Tree
·2 mins
LeetCode
Easy
Array
Divide-and-Conquer
Tree
Binary-Search-Tree
LeetCode 108 note: the middle element becomes the root and each half recurses; the halves differ by at most one, so the tree is balanced