298. Binary Tree Longest Consecutive Sequence

Problem

Find the length of the longest consecutive sequence path in a binary tree (parent to child direction only).

Given the root of a binary tree, find the length of the longest consecutive sequence path. A consecutive sequence path is one where each node's value is exactly one more than its parent (e.g., 1→2→3). The path goes from parent to child (root to leaf direction).

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

298. Binary Tree Longest Consecutive Sequence

Find the length of the longest consecutive sequence path in a binary tree (parent to child direction only).