For a rooted tree given as a parent array (parent[root] == -1), answer many lowest common ancestor queries in O(log n) each after O(n log n) preprocessing.
Unlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.
Start 7-day free trial