Problem Statement
This problem involves finding the maximum path quality in an undirected graph where paths must start and end at node 0 within a given time limit. The quality of a valid path is the sum of values of all unique nodes visited (each node's value counts only once, regardless of revisits). You can traverse edges multiple times but must respect the time constraint on total edge traversal time.[1][3][8]
Input Format
values: array of integers representing node values (index i is value of node i).edges: array of [u, v, time] where u and v are nodes connected by an edge with traversal time.maxTime: integer maximum total time allowed for the path.[3][8]Examples
Example 1:
Input: values =, edges = [,,], maxTime = 49[2][10][1][3]
Output: 75
Explanation: Path 0→1→0→3→0 takes 40 time (≤49), unique nodes 0,1,3 sum to 0+32+43=75.[3]
Example 2:
Input: values =, edges = [,,], maxTime = 30[5][10][1][2][3]
Output: 25
Explanation: Path 0→3→0 takes 20 time (≤30), unique nodes 0,3 sum to 5+20=25.[3]
Example 3:
Input: values =, edges = [,,,], maxTime = 50[4][10][1][2][3]
Output: 7
Explanation: Path 0→1→3→1→0 takes 46 time (≤50), unique nodes 0,1,3 sum to 1+2+4=7.[3]
Constraints