Search
⌘K

Leetcode 1372. Longest ZigZag Path in a Binary Tree

Given a binary tree, return the length (number of edges) of the longest path that alternates left and right at each step (a ZigZag), starting from any node. The challenge is to consider both starting directions at each node and compute this efficiently for trees up to ~5×10^4 nodes.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.

Leetcode 1372. Longest ZigZag Path in a Binary Tree | Hello Interview