mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-10-25 23:08:57 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一张 <strong>无向</strong> 图,图中有 <code>n</code> 个节点,节点编号从 <code>0</code> 到 <code>n - 1</code> (<strong>都包括</strong>)。同时给你一个下标从 <strong>0</strong> 开始的整数数组 <code>values</code> ,其中 <code>values[i]</code> 是第 <code>i</code> 个节点的 <strong>价值</strong> 。同时给你一个下标从 <strong>0</strong> 开始的二维整数数组 <code>edges</code> ,其中 <code>edges[j] = [u<sub>j</sub>, v<sub>j</sub>, time<sub>j</sub>]</code> 表示节点 <code>u<sub>j</sub></code> 和 <code>v<sub>j</sub></code> 之间有一条需要 <code>time<sub>j</sub></code> 秒才能通过的无向边。最后,给你一个整数 <code>maxTime</code> 。</p>\n\n<p><strong>合法路径</strong> 指的是图中任意一条从节点 <code>0</code> 开始,最终回到节点 <code>0</code> ,且花费的总时间 <strong>不超过</strong> <code>maxTime</code> 秒的一条路径。你可以访问一个节点任意次。一条合法路径的 <b>价值</b> 定义为路径中 <strong>不同节点</strong> 的价值 <strong>之和</strong> (每个节点的价值 <strong>至多</strong> 算入价值总和中一次)。</p>\n\n<p>请你返回一条合法路径的 <strong>最大</strong> 价值。</p>\n\n<p><strong>注意:</strong>每个节点 <strong>至多</strong> 有 <strong>四条</strong> 边与之相连。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/10/19/ex1drawio.png\" style=\"width: 269px; height: 170px;\" /></p>\n\n<pre>\n<b>输入:</b>values = [0,32,10,43], edges = [[0,1,10],[1,2,15],[0,3,10]], maxTime = 49\n<b>输出:</b>75\n<strong>解释:</strong>\n一条可能的路径为:0 -> 1 -> 0 -> 3 -> 0 。总花费时间为 10 + 10 + 10 + 10 = 40 <= 49 。\n访问过的节点为 0 ,1 和 3 ,最大路径价值为 0 + 32 + 43 = 75 。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/10/19/ex2drawio.png\" style=\"width: 269px; height: 170px;\" /></p>\n\n<pre>\n<b>输入:</b>values = [5,10,15,20], edges = [[0,1,10],[1,2,10],[0,3,10]], maxTime = 30\n<b>输出:</b>25\n<strong>解释:</strong>\n一条可能的路径为:0 -> 3 -> 0 。总花费时间为 10 + 10 = 20 <= 30 。\n访问过的节点为 0 和 3 ,最大路径价值为 5 + 20 = 25 。\n</pre>\n\n<p><strong>示例 3:</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/10/19/ex31drawio.png\" style=\"width: 236px; height: 170px;\" /></p>\n\n<pre>\n<b>输入:</b>values = [1,2,3,4], edges = [[0,1,10],[1,2,11],[2,3,12],[1,3,13]], maxTime = 50\n<b>输出:</b>7\n<strong>解释:</strong>\n一条可能的路径为:0 -> 1 -> 3 -> 1 -> 0 。总花费时间为 10 + 13 + 13 + 10 = 46 <= 50 。\n访问过的节点为 0 ,1 和 3 ,最大路径价值为 1 + 2 + 4 = 7 。</pre>\n\n<p><strong>示例 4:</strong></p>\n\n<p><strong><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2021/10/21/ex4drawio.png\" style=\"width: 270px; height: 71px;\" /></strong></p>\n\n<pre>\n<b>输入:</b>values = [0,1,2], edges = [[1,2,10]], maxTime = 10\n<b>输出:</b>0\n<b>解释:</b>\n唯一一条路径为 0 。总花费时间为 0 。\n唯一访问过的节点为 0 ,最大路径价值为 0 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>n == values.length</code></li>\n\t<li><code>1 <= n <= 1000</code></li>\n\t<li><code>0 <= values[i] <= 10<sup>8</sup></code></li>\n\t<li><code>0 <= edges.length <= 2000</code></li>\n\t<li><code>edges[j].length == 3 </code></li>\n\t<li><code>0 <= u<sub>j </sub>< v<sub>j</sub> <= n - 1</code></li>\n\t<li><code>10 <= time<sub>j</sub>, maxTime <= 100</code></li>\n\t<li><code>[u<sub>j</sub>, v<sub>j</sub>]</code> 所有节点对 <strong>互不相同</strong> 。</li>\n\t<li>每个节点 <strong>至多有四条 </strong>边。</li>\n\t<li>图可能不连通。</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Hard",
|
||||
"likes": 19,
|
||||
"likes": 20,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -149,7 +149,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"2.2K\", \"totalSubmission\": \"4.2K\", \"totalAcceptedRaw\": 2224, \"totalSubmissionRaw\": 4169, \"acRate\": \"53.3%\"}",
|
||||
"stats": "{\"totalAccepted\": \"2.3K\", \"totalSubmission\": \"4.3K\", \"totalAcceptedRaw\": 2295, \"totalSubmissionRaw\": 4277, \"acRate\": \"53.7%\"}",
|
||||
"hints": [
|
||||
"How many nodes can you visit within maxTime seconds?",
|
||||
"Can you try every valid path?"
|
||||
|
||||
Reference in New Issue
Block a user