Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 1522. Diameter of N-Ary Tree
Compute the diameter (longest path in edges between any two nodes) of an N-ary tree by using a post-order traversal to obtain subtree heights and combining the two largest child heights at each node to update a global maximum; this is a tree/DFS problem solvable in O(n) time and O(h) recursion space.
Asked at:
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Mid December, 2024
Mid-level
Solve a problem related to n-ary trees using DFS and backtracking
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.