Binary Tree Diameter Problem Statement
Given a binary tree, determine the length of its diameter. The diameter is defined as the longest path between any two end nodes in the tree. The path's length is represented by the number of edges between these nodes.
Example:
Input:
1 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -1
Output:
6
Explanation:
For the provided binary tree, the longest path between two leaf nodes results in a diameter length of 6. Nodes in this path have been highlighted.
Constraints:
1 <= T <= 10
0 <= N <= 105
1 <= data <= 104
- The time limit is 1 second.
Be the first one to answer
Add answer anonymously...
Top Paytm Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app