Given a binary tree, find the length(number of nodes) of the longest consecutive sequence(Monotonic and adjacent node values differ by 1) path.
The path could be start and end at any node in the tree
Example
No.1
Input:
{1,2,0,3}
Output:
4
Explanation:
1 | 1 |
0-1-2-3
No.2
Input:
{3,2,2}
Output:
2
Explanation:
1 | 3 |
2-3
Code
1 | public class TreeNode { |
1 | public class ResultType { |