↓Skip to main content

Lca

LeetCode 2509: Cycle Length Queries in a Tree
·2 mins
LeetCode Hard Tree Binary-Tree Lca
LeetCode 2509 note: in heap numbering the parent is v // 2, so climb the larger node until both meet at the LCA
LeetCode 865: Smallest Subtree with all the Deepest Nodes
·2 mins
LeetCode Medium Tree Binary-Tree Bfs Dfs Lca
LeetCode 865 note: BFS to the last level and climb together, or one DFS returning (depth, node)