Possible solutions

  • 0

    for formal solution from CS

      1. model this problem to a cyclic graph
      1. build the adjacent table
      1. using recursive method to travel though the adjacent table.
      1. find the max depth of the cyclic

    for solution for the issue only

    loop though and just recording the max length

    both are O(n)

Log in to reply

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