Easy O(n^2) and some hints for O(n)


  • 0
    Z

    For O(n^2):
    Go from end to start, check if the rest can form a tree, this one will get AC surprisingly.

    For O(n):
    If we have a node with two parent, the answer must be the one of them.
    Else, the answer is the first one that form a loop.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.