leetle

Daily challenge for 2026-09-23

631. Tree Path Value Parity

Given a non-empty tree of n nodes labeled from 0 to n - 1, represented as an undirected list of edges edges, and an array of node values values of length n, return the maximum sum of node values along any simple path in the tree that contains an odd number of nodes.

Example:
Input: values = [2, -10, 3], edges = [[0, 1], [1, 2]]
Output: 3

Constraints: 1 <= n <= 200; node values are integers between -10000 and 10000. A single node is a valid path.

Run this challenge interactively in Python or JavaScript when the app loads.