Computer Science, asked by koehai9430, 3 months ago

You are given a tree of size N rooted at node 1.
The edges are given by the vector P of size N-1 where ith element represents an edge between i+1 and P[i]. (1-based indexing)
You need to answer Q queries on it.
In each query, you are given L and R.
You need to find such a node V such that all leaves with labels between L and R inclusive, lie in its subtree.
The node V should also be at maximum height as possible.
If there does not exist any leaf with label between L to R, return -1 for that query.​

Answers

Answered by TheRiskyGuy
2

Answer:

\huge\tt\colorbox{Orange}{\color{white}{Happy}}

\huge\tt\colorbox{blue}{\color{white}{Republic}}

\huge\tt\colorbox{green}{\color{white}{Day}}

Similar questions