Lowest Common Ancestor
There are many ways to solve the LCA problem.
- Binary Lifting, preprocessing, for each query
- Sparse Table, preprocessing, for each query
For regular LeetCode, one of the ways you can approach is doing it recursively.
Search
There are many ways to solve the LCA problem.
For regular LeetCode, one of the ways you can approach is doing it recursively.