leetcode.cn 2023-12-06
🔴2646.minimize-the-total-price-of-the-trips
🏷️ Tags
#tree #depth_first_search #graph #array #dynamic_programming
🔴2646.minimize-the-total-price-of-the-trips
🏷️ Tags
#tree #depth_first_search #graph #array #dynamic_programming
Telegraph
minimize-the-total-price-of-the-trips
现有一棵无向、无根的树,树中有 n 个节点,按从 0 到 n - 1 编号。给你一个整数 n 和一个长度为 n - 1 的二维整数数组 edges ,其中 edges[i] = [ai, bi] 表示树中节点 ai 和 bi 之间存在一条边。 每个节点都关联一个价格。给你一个整数数组 price ,其中 price[i] 是第 i 个节点的价格。 给定路径的 价格总和 是该路径上所有节点的价格之和。 另给你一个二维整数数组 trips ,其中 trips[i] = [starti, endi] 表示您从节点…