mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-09 01:11:42 +08:00
移除零宽空格
This commit is contained in:
@@ -7,9 +7,9 @@
|
||||
"boundTopicId": 569360,
|
||||
"title": "Minimum Number of People to Teach",
|
||||
"titleSlug": "minimum-number-of-people-to-teach",
|
||||
"content": "<p>On a social network consisting of <code>m</code> users and some friendships between users, two users can communicate with each other if they know a common language.</p>\n\n<p>You are given an integer <code>n</code>, an array <code>languages</code>, and an array <code>friendships</code> where:</p>\n\n<ul>\n\t<li>There are <code>n</code> languages numbered <code>1</code> through <code>n</code>,</li>\n\t<li><code>languages[i]</code> is the set of languages the <code>i<sup>th</sup></code> user knows, and</li>\n\t<li><code>friendships[i] = [u<sub>i</sub>, v<sub>i</sub>]</code> denotes a friendship between the users <code>u<sup></sup><sub>i</sub></code> and <code>v<sub>i</sub></code>.</li>\n</ul>\n\n<p>You can choose <strong>one</strong> language and teach it to some users so that all friends can communicate with each other. Return <i data-stringify-type=\"italic\">the</i> <i><strong>minimum</strong> </i><i data-stringify-type=\"italic\">number of users you need to teach.</i></p>\nNote that friendships are not transitive, meaning if <code>x</code> is a friend of <code>y</code> and <code>y</code> is a friend of <code>z</code>, this doesn't guarantee that <code>x</code> is a friend of <code>z</code>.\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> n = 2, languages = [[1],[2],[1,2]], friendships = [[1,2],[1,3],[2,3]]\n<strong>Output:</strong> 1\n<strong>Explanation:</strong> You can either teach user 1 the second language or user 2 the first language.\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> n = 3, languages = [[2],[1,3],[1,2],[3]], friendships = [[1,4],[1,2],[3,4],[2,3]]\n<strong>Output:</strong> 2\n<strong>Explanation:</strong> Teach the third language to users 1 and 3, yielding two users to teach.\n</pre>\n\n<p> </p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>2 <= n <= 500</code></li>\n\t<li><code>languages.length == m</code></li>\n\t<li><code>1 <= m <= 500</code></li>\n\t<li><code>1 <= languages[i].length <= n</code></li>\n\t<li><code>1 <= languages[i][j] <= n</code></li>\n\t<li><code>1 <= u<sub>i</sub> < v<sub>i</sub> <= languages.length</code></li>\n\t<li><code>1 <= friendships.length <= 500</code></li>\n\t<li>All tuples <code>(u<sub>i, </sub>v<sub>i</sub>)</code> are unique</li>\n\t<li><code>languages[i]</code> contains only unique values</li>\n</ul>\n",
|
||||
"content": "<p>On a social network consisting of <code>m</code> users and some friendships between users, two users can communicate with each other if they know a common language.</p>\n\n<p>You are given an integer <code>n</code>, an array <code>languages</code>, and an array <code>friendships</code> where:</p>\n\n<ul>\n\t<li>There are <code>n</code> languages numbered <code>1</code> through <code>n</code>,</li>\n\t<li><code>languages[i]</code> is the set of languages the <code>i<sup>th</sup></code> user knows, and</li>\n\t<li><code>friendships[i] = [u<sub>i</sub>, v<sub>i</sub>]</code> denotes a friendship between the users <code>u<sup></sup><sub>i</sub></code> and <code>v<sub>i</sub></code>.</li>\n</ul>\n\n<p>You can choose <strong>one</strong> language and teach it to some users so that all friends can communicate with each other. Return <i data-stringify-type=\"italic\">the</i> <i><strong>minimum</strong> </i><i data-stringify-type=\"italic\">number of users you need to teach.</i></p>\nNote that friendships are not transitive, meaning if <code>x</code> is a friend of <code>y</code> and <code>y</code> is a friend of <code>z</code>, this doesn't guarantee that <code>x</code> is a friend of <code>z</code>.\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> n = 2, languages = [[1],[2],[1,2]], friendships = [[1,2],[1,3],[2,3]]\n<strong>Output:</strong> 1\n<strong>Explanation:</strong> You can either teach user 1 the second language or user 2 the first language.\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> n = 3, languages = [[2],[1,3],[1,2],[3]], friendships = [[1,4],[1,2],[3,4],[2,3]]\n<strong>Output:</strong> 2\n<strong>Explanation:</strong> Teach the third language to users 1 and 3, yielding two users to teach.\n</pre>\n\n<p> </p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>2 <= n <= 500</code></li>\n\t<li><code>languages.length == m</code></li>\n\t<li><code>1 <= m <= 500</code></li>\n\t<li><code>1 <= languages[i].length <= n</code></li>\n\t<li><code>1 <= languages[i][j] <= n</code></li>\n\t<li><code>1 <= u<sub>i</sub> < v<sub>i</sub> <= languages.length</code></li>\n\t<li><code>1 <= friendships.length <= 500</code></li>\n\t<li>All tuples <code>(u<sub>i, </sub>v<sub>i</sub>)</code> are unique</li>\n\t<li><code>languages[i]</code> contains only unique values</li>\n</ul>\n",
|
||||
"translatedTitle": "需要教语言的最少人数",
|
||||
"translatedContent": "<p>在一个由 <code>m</code> 个用户组成的社交网络里,我们获取到一些用户之间的好友关系。两个用户之间可以相互沟通的条件是他们都掌握同一门语言。</p>\n\n<p>给你一个整数 <code>n</code> ,数组 <code>languages</code> 和数组 <code>friendships</code> ,它们的含义如下:</p>\n\n<ul>\n\t<li>总共有 <code>n</code> 种语言,编号从 <code>1</code> 到 <code>n</code> 。</li>\n\t<li><code>languages[i]</code> 是第 <code>i</code> 位用户掌握的语言集合。</li>\n\t<li><code>friendships[i] = [u<sub>i</sub>, v<sub>i</sub>]</code> 表示 <code>u<sup></sup><sub>i</sub></code> 和 <code>v<sub>i</sub></code> 为好友关系。</li>\n</ul>\n\n<p>你可以选择 <strong>一门</strong> 语言并教会一些用户,使得所有好友之间都可以相互沟通。请返回你 <strong>最少</strong> 需要教会多少名用户。</p>\n请注意,好友关系没有传递性,也就是说如果 <code>x</code> 和 <code>y</code> 是好友,且 <code>y</code> 和 <code>z</code> 是好友, <code>x</code> 和 <code>z</code> 不一定是好友。\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<b>输入:</b>n = 2, languages = [[1],[2],[1,2]], friendships = [[1,2],[1,3],[2,3]]\n<b>输出:</b>1\n<b>解释:</b>你可以选择教用户 1 第二门语言,也可以选择教用户 2 第一门语言。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<b>输入:</b>n = 3, languages = [[2],[1,3],[1,2],[3]], friendships = [[1,4],[1,2],[3,4],[2,3]]\n<b>输出:</b>2\n<b>解释:</b>教用户 1 和用户 3 第三门语言,需要教 2 名用户。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>2 <= n <= 500</code></li>\n\t<li><code>languages.length == m</code></li>\n\t<li><code>1 <= m <= 500</code></li>\n\t<li><code>1 <= languages[i].length <= n</code></li>\n\t<li><code>1 <= languages[i][j] <= n</code></li>\n\t<li><code>1 <= u<sub>i</sub> < v<sub>i</sub> <= languages.length</code></li>\n\t<li><code>1 <= friendships.length <= 500</code></li>\n\t<li>所有的好友关系 <code>(u<sub>i, </sub>v<sub>i</sub>)</code> 都是唯一的。</li>\n\t<li><code>languages[i]</code> 中包含的值互不相同。</li>\n</ul>\n",
|
||||
"translatedContent": "<p>在一个由 <code>m</code> 个用户组成的社交网络里,我们获取到一些用户之间的好友关系。两个用户之间可以相互沟通的条件是他们都掌握同一门语言。</p>\n\n<p>给你一个整数 <code>n</code> ,数组 <code>languages</code> 和数组 <code>friendships</code> ,它们的含义如下:</p>\n\n<ul>\n\t<li>总共有 <code>n</code> 种语言,编号从 <code>1</code> 到 <code>n</code> 。</li>\n\t<li><code>languages[i]</code> 是第 <code>i</code> 位用户掌握的语言集合。</li>\n\t<li><code>friendships[i] = [u<sub>i</sub>, v<sub>i</sub>]</code> 表示 <code>u<sup></sup><sub>i</sub></code> 和 <code>v<sub>i</sub></code> 为好友关系。</li>\n</ul>\n\n<p>你可以选择 <strong>一门</strong> 语言并教会一些用户,使得所有好友之间都可以相互沟通。请返回你 <strong>最少</strong> 需要教会多少名用户。</p>\n请注意,好友关系没有传递性,也就是说如果 <code>x</code> 和 <code>y</code> 是好友,且 <code>y</code> 和 <code>z</code> 是好友, <code>x</code> 和 <code>z</code> 不一定是好友。\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<b>输入:</b>n = 2, languages = [[1],[2],[1,2]], friendships = [[1,2],[1,3],[2,3]]\n<b>输出:</b>1\n<b>解释:</b>你可以选择教用户 1 第二门语言,也可以选择教用户 2 第一门语言。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<b>输入:</b>n = 3, languages = [[2],[1,3],[1,2],[3]], friendships = [[1,4],[1,2],[3,4],[2,3]]\n<b>输出:</b>2\n<b>解释:</b>教用户 1 和用户 3 第三门语言,需要教 2 名用户。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>2 <= n <= 500</code></li>\n\t<li><code>languages.length == m</code></li>\n\t<li><code>1 <= m <= 500</code></li>\n\t<li><code>1 <= languages[i].length <= n</code></li>\n\t<li><code>1 <= languages[i][j] <= n</code></li>\n\t<li><code>1 <= u<sub>i</sub> < v<sub>i</sub> <= languages.length</code></li>\n\t<li><code>1 <= friendships.length <= 500</code></li>\n\t<li>所有的好友关系 <code>(u<sub>i, </sub>v<sub>i</sub>)</code> 都是唯一的。</li>\n\t<li><code>languages[i]</code> 中包含的值互不相同。</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 28,
|
||||
|
Reference in New Issue
Block a user