Leetcode 1483. Kth Ancestor of a Tree Node
Given a rooted tree as a parent[] array, preprocess it to efficiently answer many queries asking for the k-th ancestor of a node (return -1 if it doesn't exist). The core challenge is supporting up to ~5·10^4 nodes/queries by using a log-depth jump-pointer (binary lifting) structure to achieve fast queries after preprocessing.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.