leetcode.cn 2023-12-05
🟡2477.minimum-fuel-cost-to-report-to-the-capital
🏷️ Tags
#tree #depth_first_search #breadth_first_search #graph
🟡2477.minimum-fuel-cost-to-report-to-the-capital
🏷️ Tags
#tree #depth_first_search #breadth_first_search #graph
Telegraph
minimum-fuel-cost-to-report-to-the-capital
给你一棵 n 个节点的树(一个无向、连通、无环图),每个节点表示一个城市,编号从 0 到 n - 1 ,且恰好有 n - 1 条路。0 是首都。给你一个二维整数数组 roads ,其中 roads[i] = [ai, bi] ,表示城市 ai 和 bi 之间有一条 双向路 。 每个城市里有一个代表,他们都要去首都参加一个会议。 每座城市里有一辆车。给你一个整数 seats 表示每辆车里面座位的数目。 城市里的代表可以选择乘坐所在城市的车,或者乘坐其他城市的车。相邻城市之间一辆车的油耗是一升汽油。 请你返回到达首都最少需要多少升汽油。…
❤1
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] 表示您从节点…