Doubts about the question: Why we use topological sort?


  • 1

    I have not solved this problem yet.

    I just have some doubts.

    If we use topological sort to solve this problem, does it mean that any sequence in the seqs must not have loops?

    e.g.

    seq = [[1,2,1]]
    org = [1,2,1]
    

    What is the expected result? True? But the accepted code gives False.

    Does it imply that the org and seqs must not contain duplicated numbers?


  • 1

    Would it be better to clearly say that the permutation does not contain duplicated elements? @1337c0d3r


  • 0
    I

    I agree with you. The context of using topological sort is that we are facing an acyclic graph.


  • 0
    X

    "The org sequence is a permutation of the integers from 1 to n"

    Would there be duplicates for integers from 1 to n?


Log in to reply
 

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