Kth Ancestor of a Tree Node
You are given a tree withnnodes numbered from0ton-1in the form of a parent array whereparent[i]is the parent of nodei. The root of the tree is node0.
Implement the functiongetKthAncestor(int node, int k)to return thek-th ancestor of the given...
原创
2020-06-14 12:40:07 ·
368 阅读 ·
0 评论