Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root.
https://leetcode.com/explore/challenge/card/30-day-leetcoding-challenge/529/week-2/3293/
>> Solution 1 - Use DFS with Recursion
>> Solution 2 - Use Post Order DFS with Two Stacks
See
- https://www.geeksforgeeks.org/dfs-traversal-of-a-tree-using-recursion/
- https://www.geeksforgeeks.org/iterative-postorder-traversal/
Hiç yorum yok:
Yorum Gönder