# 0298. Binary Tree Longest Consecutive Sequence

https://leetcode.com/problems/binary-tree-longest-consecutive-sequence

## Description

Given the `root` of a binary tree, return _the length of the longest consecutive sequence path_.

The path refers to any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The longest consecutive path needs to be from parent to child (cannot be the reverse).

**Example 1:**

![](https://assets.leetcode.com/uploads/2021/03/14/consec1-1-tree.jpg)

```
**Input:** root = [1,null,3,2,4,null,null,null,5]
**Output:** 3
**Explanation:** Longest consecutive sequence path is 3-4-5, so return 3.
```

**Example 2:**

![](https://assets.leetcode.com/uploads/2021/03/14/consec1-2-tree.jpg)

```
**Input:** root = [2,null,3,2,null,1]
**Output:** 2
**Explanation:** Longest consecutive sequence path is 2-3, not 3-2-1, so return 2.
```

**Constraints:**

* The number of nodes in the tree is in the range `[1, 3 * 104]`.
* `-3 * 104 <= Node.val <= 3 * 104`

## ac

```java
```
