← ALL NOTES
Dynamic Programming

1372. Longest ZigZag Path in a Binary Tree

A ZigZag path starts anywhere, picks a direction (left/right), and alternates direction each step; its length is the edge count. Find the longest ZigZag path. The trick is that at each node you track…

Loading…