Pth cousins question

Revision en1, by Arunnsit, 2016-03-25 16:55:17

hello guys , so i was trying to solve a question and came up with this one.

Given a tree with N nodes , you need to find the number of Pth cousins . where a Pth cousin is defined as a pair of nodes x,y and there exists a node z which is Pth ancestor of both x and y . you need to print an array of n integers each denoting the count of ith cousins , where 1<=i<=n .

1<n<=100000

Tags trees, lca

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Arunnsit 2016-03-25 16:55:17 405 Initial revision (published)