Ejemplo n.º 1
0
    private static int FindTheLongestPath(TreeNode<int> node)
    {
        if (node.ChildrenCount == 0)
        {
            return 0;
        }

        int maxPath = 0;

        foreach (var currentChild in node.GetChildNodes())
        {
            maxPath = Math.Max(maxPath, FindTheLongestPath(currentChild));
        }

        return maxPath + 1;
    }