Longest Even Value Path
Given a binary tree root
, return the longest path consisting of even values between any two nodes in the tree.
Constraints
n ≤ 100,000
wheren
is the number of nodes inroot
https://binarysearch.com/problems/Longest-Even-Value-Path
Examples
Example 1
Input
- root =
Output
- answer =
5
Explanation
A longest path is [8, 0, 2, 6, 4]
Example 2
Input
- root =
Output
- answer =
4
Explanation
A longest path is [0, 2, 8, 4]
.
Leave a comment