topic:
Thought:
一开始的想法是构建有向picture,然后在有向picture中找到queryDoes the two points have a father -son relationship?。
But watchylbAfter the answer,I find that the accessability is faster first。
First traversalprerequirements,Record all the accessibility。
Then triple cycle,Connect all the availability。
i->j->k,ifi->k,Soi->kIt is。
Code:
1 | class Solution: |