Maximum Path Quality of a Graph
You are given a weighted undirected graph with n nodes labeled from 0 to n - 1, an array values where values[i] is the value of node i, an array edges where each entry [u, v, time] is a road joining u and v that costs time to travel, and an integer maxTime. At most four edges are incident to any node, and the graph may be disconnected. You start at node 0 and you must return to node 0 within maxTime total travel time. You may revisit nodes and edges any number of times. The quality of a walk is the sum of values[i] over the distinct nodes the walk visits, so a node value is counted at most once even when the node is visited several times. Return the maximum quality over every closed walk that starts and ends at node 0 and fits inside maxTime. When no closed walk has positive quality, the answer is 0.