Amazon Interview Question

Sliding window based question on array , Finding the ancestor of a root node in trees