Tap here to switch tabs
Problem
Submissions

Problem: Longest Univalue Path

Try to solve the Longest Univalue Path problem.

Statement

Given the root of a binary tree, return the length of the longest path where every node along the path possesses the same value. The path is not required to pass through the root.

Note: The length of the path between two nodes is defined by the number of edges connecting them.

Constraints:

  • The number of nodes in the tree is in the range [0,104][0, 10^4].

  • −1000≤-1000 \leq Node.val ≤1000\leq 1000

  • The depth of the tree will not exceed 10001000.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Longest Univalue Path

Try to solve the Longest Univalue Path problem.

Statement

Given the root of a binary tree, return the length of the longest path where every node along the path possesses the same value. The path is not required to pass through the root.

Note: The length of the path between two nodes is defined by the number of edges connecting them.

Constraints:

  • The number of nodes in the tree is in the range [0,104][0, 10^4].

  • −1000≤-1000 \leq Node.val ≤1000\leq 1000

  • The depth of the tree will not exceed 10001000.