549. Binary Tree Longest Consecutive Sequence II

Given the root of a binary tree, return the length of the longest consecutive path in the tree.

A consecutive path is a path where the values along the nodes form a consecutive sequence (e.g., 1, 2, 3, ...). The path can go from parent to child or from child to parent - it can traverse through any connected nodes in the tree.

The path does not need to start or end at the root or a leaf; it can be any path in the tree where values are consecutive.

Examples
Input: [1,2,3]
Output: 2
Hints
Related Problems

549. Binary Tree Longest Consecutive Sequence II

Given the root of a binary tree, return the length of the longest consecutive path in the tree.