Skip to content

feat: update lc problems #3286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion solution/0000-0099/0013.Roman to Integer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ M 1000</pre>
<li>题目数据保证 <code>s</code> 是一个有效的罗马数字,且表示整数在范围 <code>[1, 3999]</code> 内</li>
<li>题目所给测试用例皆符合罗马数字书写规则,不会出现跨位等情况。</li>
<li>IL 和 IM 这样的例子并不符合题目要求,49 应该写作 XLIX,999 应该写作 CMXCIX 。</li>
<li>关于罗马数字的详尽书写规则,可以参考 <a href="https://b2b.partcommunity.com/community/knowledge/zh_CN/detail/10753/%E7%BD%97%E9%A9%AC%E6%95%B0%E5%AD%97#knowledge_article">罗马数字 - Mathematics </a>。</li>
<li>关于罗马数字的详尽书写规则,可以参考 <a href="https://baike.baidu.com/item/%E7%BD%97%E9%A9%AC%E6%95%B0%E5%AD%97/772296">罗马数字 - 百度百科</a>。</li>
</ul>

<!-- description:end -->
Expand Down
23 changes: 13 additions & 10 deletions solution/0000-0099/0091.Decode Ways/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,25 @@ tags:

<p>一条包含字母&nbsp;<code>A-Z</code> 的消息通过以下映射进行了 <strong>编码</strong> :</p>

<pre>
'A' -&gt; "1"
'B' -&gt; "2"
...
'Z' -&gt; "26"</pre>
<p><code>"1" -&gt; 'A'<br />
"2" -&gt; 'B'<br />
...<br />
"25" -&gt; 'Y'<br />
"26" -&gt; 'Z'</code></p>

<p>然而,在&nbsp;<strong>解码</strong> 已编码的消息时,你意识到有许多不同的方式来解码,因为有些编码被包含在其它编码当中(<code>"2"</code> 和 <code>"5"</code> 与 <code>"25"</code>)。</p>

<p>要 <strong>解码</strong> 已编码的消息,所有数字必须基于上述映射的方法,反向映射回字母(可能有多种方法)。例如,<code>"11106"</code> 可以映射为:</p>
<p>例如,<code>"11106"</code> 可以映射为:</p>

<ul>
<li><code>"AAJF"</code> ,将消息分组为 <code>(1 1 10 6)</code></li>
<li><code>"KJF"</code> ,将消息分组为 <code>(11 10 6)</code></li>
<li><code>"AAJF"</code> ,将消息分组为 <code>(1, 1, 10, 6)</code></li>
<li><code>"KJF"</code> ,将消息分组为 <code>(11, 10, 6)</code></li>
<li>消息不能分组为&nbsp; <code>(1, 11, 06)</code> ,因为 <code>"06"</code>&nbsp;不是一个合法编码(只有 "6" 是合法的)。</li>
</ul>

<p>注意,消息不能分组为&nbsp; <code>(1 11 06)</code> ,因为 <code>"06"</code> 不能映射为 <code>"F"</code> ,这是由于 <code>"6"</code> 和 <code>"06"</code> 在映射中并不等价。</p>
<p>注意,可能存在无法解码的字符串。</p>

<p>给你一个只含数字的 <strong>非空 </strong>字符串 <code>s</code> ,请计算并返回 <strong>解码</strong> 方法的 <strong>总数</strong> 。</p>
<p>给你一个只含数字的 <strong>非空 </strong>字符串 <code>s</code> ,请计算并返回 <strong>解码</strong> 方法的 <strong>总数</strong> 。如果没有合法的方式解码整个字符串,返回 <code>0</code>。</p>

<p>题目数据保证答案肯定是一个 <strong>32 位</strong> 的整数。</p>

Expand Down
41 changes: 20 additions & 21 deletions solution/0900-0999/0999.Available Captures for Rook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,59 +18,58 @@ tags:

<!-- description:start -->

<p>在一个 8 x 8 的棋盘上,有一个白色的车(<code>Rook</code>),用字符 <code>&#39;R&#39;</code> 表示。棋盘上还可能存在空方块,白色的象(<code>Bishop</code>)以及黑色的卒(<code>pawn</code>),分别用字符 <code>&#39;.&#39;</code>,<code>&#39;B&#39;</code><code>&#39;p&#39;</code> 表示。不难看出,大写字符表示的是白棋,小写字符表示的是黑棋。</p>
<p>给定一个&nbsp;<code>8 x 8</code> 的棋盘,<strong>只有一个</strong> 白色的车,用字符 <code>'R'</code> 表示。棋盘上还可能存在白色的象&nbsp;<code>'B'</code>&nbsp;以及黑色的卒&nbsp;<code>'p'</code>。空方块用字符 <code>'.'</code>&nbsp;表示。</p>

<p>车按国际象棋中的规则移动。东,西,南,北四个基本方向任选其一,然后一直向选定的方向移动,直到满足下列四个条件之一:</p>
<p>车可以按水平或竖直方向(上,下,左,右)移动任意个方格直到它遇到另一个棋子或棋盘的边界。如果它能够在一次移动中移动到棋子的方格,则能够 <strong>吃掉</strong> 棋子。</p>

<ul>
<li>棋手选择主动停下来。</li>
<li>棋子因到达棋盘的边缘而停下。</li>
<li>棋子移动到某一方格来捕获位于该方格上敌方(黑色)的卒,停在该方格内。</li>
<li>车不能进入/越过已经放有其他友方棋子(白色的象)的方格,停在友方棋子前。</li>
</ul>
<p>注意:车不能穿过其它棋子,比如象和卒。这意味着如果有其它棋子挡住了路径,车就不能够吃掉棋子。</p>

<p>你现在可以控制车移动一次,请你统计有多少敌方的卒处于你的捕获范围内(即,可以被一步捕获的棋子数)。</p>
<p>返回白车将能 <strong>吃掉</strong> 的 <strong>卒的数量</strong>。</p>

<p>&nbsp;</p>

<p><strong>示例 1:</strong></p>

<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0900-0999/0999.Available%20Captures%20for%20Rook/images/1253_example_1_improved.png" style="height: 305px; width: 300px;"></p>
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0900-0999/0999.Available%20Captures%20for%20Rook/images/1253_example_1_improved.png" style="height: 305px; width: 300px;" /></p>

<pre><strong>输入:</strong>[[&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;],[&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;p&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;],[&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;R&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;p&quot;],[&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;],[&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;],[&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;p&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;],[&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;],[&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;]]
<pre>
<strong>输入:</strong>[[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".","R",".",".",".","p"],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."]]
<strong>输出:</strong>3
<strong>解释:
</strong>在本例中,车能够捕获所有的卒
</strong>在本例中,车能够吃掉所有的卒
</pre>

<p><strong>示例 2:</strong></p>

<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0900-0999/0999.Available%20Captures%20for%20Rook/images/1253_example_2_improved.png" style="height: 306px; width: 300px;"></p>
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0900-0999/0999.Available%20Captures%20for%20Rook/images/1253_example_2_improved.png" style="height: 306px; width: 300px;" /></p>

<pre><strong>输入:</strong>[[&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;],[&quot;.&quot;,&quot;p&quot;,&quot;p&quot;,&quot;p&quot;,&quot;p&quot;,&quot;p&quot;,&quot;.&quot;,&quot;.&quot;],[&quot;.&quot;,&quot;p&quot;,&quot;p&quot;,&quot;B&quot;,&quot;p&quot;,&quot;p&quot;,&quot;.&quot;,&quot;.&quot;],[&quot;.&quot;,&quot;p&quot;,&quot;B&quot;,&quot;R&quot;,&quot;B&quot;,&quot;p&quot;,&quot;.&quot;,&quot;.&quot;],[&quot;.&quot;,&quot;p&quot;,&quot;p&quot;,&quot;B&quot;,&quot;p&quot;,&quot;p&quot;,&quot;.&quot;,&quot;.&quot;],[&quot;.&quot;,&quot;p&quot;,&quot;p&quot;,&quot;p&quot;,&quot;p&quot;,&quot;p&quot;,&quot;.&quot;,&quot;.&quot;],[&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;],[&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;]]
<pre>
<strong>输入:</strong>[[".",".",".",".",".",".",".","."],[".","p","p","p","p","p",".","."],[".","p","p","B","p","p",".","."],[".","p","B","R","B","p",".","."],[".","p","p","B","p","p",".","."],[".","p","p","p","p","p",".","."],[".",".",".",".",".",".",".","."],[".",".",".",".",".",".",".","."]]
<strong>输出:</strong>0
<strong>解释:
</strong>象阻止了车捕获任何卒
</strong>象阻止了车吃掉任何卒
</pre>

<p><strong>示例 3:</strong></p>

<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0900-0999/0999.Available%20Captures%20for%20Rook/images/1253_example_3_improved.png" style="height: 305px; width: 300px;"></p>
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0900-0999/0999.Available%20Captures%20for%20Rook/images/1253_example_3_improved.png" style="height: 305px; width: 300px;" /></p>

<pre><strong>输入:</strong>[[&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;],[&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;p&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;],[&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;p&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;],[&quot;p&quot;,&quot;p&quot;,&quot;.&quot;,&quot;R&quot;,&quot;.&quot;,&quot;p&quot;,&quot;B&quot;,&quot;.&quot;],[&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;],[&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;B&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;],[&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;p&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;],[&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;,&quot;.&quot;]]
<pre>
<strong>输入:</strong>[[".",".",".",".",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".","p",".",".",".","."],["p","p",".","R",".","p","B","."],[".",".",".",".",".",".",".","."],[".",".",".","B",".",".",".","."],[".",".",".","p",".",".",".","."],[".",".",".",".",".",".",".","."]]
<strong>输出:</strong>3
<strong>解释: </strong>
车可以捕获位置 b5,d6 和 f5 的卒。
车可以吃掉位置 b5,d6 和 f5 的卒。
</pre>

<p>&nbsp;</p>

<p><strong>提示:</strong></p>

<ol>
<li><code>board.length == board[i].length == 8</code></li>
<li><code>board[i][j]</code> 可以是&nbsp;<code>&#39;R&#39;</code>,<code>&#39;.&#39;</code>,<code>&#39;B&#39;</code>&nbsp;或&nbsp;<code>&#39;p&#39;</code></li>
<li>只有一个格子上存在&nbsp;<code>board[i][j] == &#39;R&#39;</code></li>
<li><code>board.length == 8</code></li>
<li><code>board[i].length == 8</code></li>
<li><code>board[i][j]</code> 可以是&nbsp;<code>'R'</code>,<code>'.'</code>,<code>'B'</code>&nbsp;或&nbsp;<code>'p'</code></li>
<li>只有一个格子上存在&nbsp;<code>board[i][j] == 'R'</code></li>
</ol>

<!-- description:end -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/1700-1799/1788.Ma
tags:
- 贪心
- 数组
- 哈希表
- 前缀和
---

Expand All @@ -18,7 +19,7 @@ tags:

<!-- description:start -->

<p>有一个花园,有 <code>n</code> 朵花,这些花都有一个用整数表示的美观度。这些花被种在一条线上。给定一个长度为 <code>n</code> 的整数类型数组 <code>flowers</code> ,每一个 <code>flowers[i]</code> 表示第 <code>i</code> 朵花的美观度。</p>
<p>有一个花园,有&nbsp;<code>n</code>&nbsp;朵花,这些花都有一个用整数表示的美观度。这些花被种在一条线上。给定一个长度为 <code>n</code> 的整数类型数组&nbsp;<code>flowers</code>&nbsp;,每一个&nbsp;<code>flowers[i]</code>&nbsp;表示第&nbsp;<code>i</code>&nbsp;朵花的美观度。</p>

<p>一个花园满足下列条件时,该花园是<strong>有效</strong>的。</p>

Expand All @@ -31,29 +32,32 @@ tags:

<p>返回你去除了任意朵花(也可以不去除任意一朵)之后形成的<strong>有效</strong>花园中最大可能的美观度。</p>

<p> </p>
<p>&nbsp;</p>

<p><b>示例 1:</b></p>
<p><b class="example">示例 1:</b></p>

<pre><strong>输入:</strong> flowers = [1,2,3,1,2]
<pre>
<strong>输入:</strong> flowers = [1,2,3,1,2]
<strong>输出:</strong> 8
<strong>解释:</strong> 你可以修整为有效花园 [2,3,1,2] 来达到总美观度 2 + 3 + 1 + 2 = 8。</pre>

<p><strong>示例 2:</strong></p>
<p><strong class="example">示例 2:</strong></p>

<pre><strong>输入:</strong> flowers = [100,1,1,-3,1]
<pre>
<strong>输入:</strong> flowers = [100,1,1,-3,1]
<strong>输出:</strong> 3
<strong>解释:</strong> 你可以修整为有效花园 [1,1,1] 来达到总美观度 1 + 1 + 1 = 3。
</pre>

<p><strong>示例 3:</strong></p>
<p><strong class="example">示例 3:</strong></p>

<pre><strong>输入:</strong> flowers = [-1,-2,0,-1]
<pre>
<strong>输入:</strong> flowers = [-1,-2,0,-1]
<strong>输出:</strong> -2
<strong>解释:</strong> 你可以修整为有效花园 [-1,-1] 来达到总美观度 -1 + -1 = -2。
</pre>

<p> </p>
<p>&nbsp;</p>

<p><b>提示:</b></p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/1700-1799/1788.Ma
tags:
- Greedy
- Array
- Hash Table
- Prefix Sum
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ rating: 2502
source: 第 250 场周赛 Q4
tags:
- 位运算
- 深度优先搜索
- 字典树
- 数组
- 哈希表
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ rating: 2502
source: Weekly Contest 250 Q4
tags:
- Bit Manipulation
- Depth-First Search
- Trie
- Array
- Hash Table
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ tags:
- 贪心
- 哈希表
- 字符串
- 计数
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ tags:
- Greedy
- Hash Table
- String
- Counting
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ rating: 2023
source: 第 337 场周赛 Q3
tags:
- 数组
- 哈希表
- 数学
- 动态规划
- 回溯
- 组合数学
- 排序
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ rating: 2023
source: Weekly Contest 337 Q3
tags:
- Array
- Hash Table
- Math
- Dynamic Programming
- Backtracking
- Combinatorics
- Sorting
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/2600-2699/2638.Count%20the%20Number%20of%20K-Free%20Subsets/README.md
tags:
- 数组
- 数学
- 动态规划
- 组合数学
- 排序
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/2600-2699/2638.Count%20the%20Number%20of%20K-Free%20Subsets/README_EN.md
tags:
- Array
- Math
- Dynamic Programming
- Combinatorics
- Sorting
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,54 @@ tags:

<!-- description:start -->

<p>给你两个下标从 <strong>0</strong>&nbsp;开始的整数数组&nbsp;<code>nums1</code>&nbsp;&nbsp;<code>nums2</code>&nbsp;,它们分别含有 <code>n</code>&nbsp;和 <code>m</code>&nbsp;个元素。</p>

<p>请你计算以下两个数值:</p>
<p>给你两个下标从 <strong>0</strong>&nbsp;开始的整数数组&nbsp;<code>nums1</code>&nbsp;&nbsp;<code>nums2</code>&nbsp;,它们分别含有 <code>n</code>&nbsp;和 <code>m</code>&nbsp;个元素。请你计算以下两个数值:</p>

<ul>
<li>统计&nbsp;<code>0 &lt;= i &lt; n</code>&nbsp;中的下标&nbsp;<code>i</code>&nbsp;,满足&nbsp;<code>nums1[i]</code>&nbsp;在 <code>nums2</code>&nbsp;中 <strong>至少</strong>&nbsp;出现了一次。</li>
<li>统计&nbsp;<code>0 &lt;= i &lt; m</code>&nbsp;中的下标&nbsp;<code>i</code>&nbsp;,满足&nbsp;<code>nums2[i]</code>&nbsp;在 <code>nums1</code>&nbsp;中 <strong>至少</strong>&nbsp;出现了一次。</li>
<li><code>answer1</code>:使得&nbsp;<code>nums1[i]</code>&nbsp;&nbsp;<code>nums2</code>&nbsp;中出现的下标&nbsp;<code>i</code>&nbsp;的数量。</li>
<li><code>answer2</code>:使得&nbsp;<code>nums2[i]</code>&nbsp;&nbsp;<code>nums1</code>&nbsp;中出现的下标&nbsp;<code>i</code>&nbsp;的数量。</li>
</ul>

<p>请你返回一个长度为 <code>2</code>&nbsp;的整数数组<em>&nbsp;</em><code>answer</code>&nbsp;,<strong>按顺序</strong>&nbsp;分别为以上两个数值。</p>
<p>返回 <code>[answer1, answer2]</code>。</p>

<p>&nbsp;</p>

<p><strong class="example">示例 1:</strong></p>

<pre>
<strong>输入:</strong>nums1 = [4,3,2,3,1], nums2 = [2,2,5,2,3,6]
<b>输出:</b>[3,4]
<b>解释:</b>分别计算两个数值:
- nums1 中下标为 1 ,2 和 3 的元素在 nums2 中至少出现了一次,所以第一个值为 3 。
- nums2 中下标为 0 ,1 ,3 和 4 的元素在 nums1 中至少出现了一次,所以第二个值为 4 。
</pre>
<div class="example-block">
<p><strong>输入:</strong><span class="example-io">nums1 = [2,3,2], nums2 = [1,2]</span></p>

<p><strong>输出:</strong><span class="example-io">[2,1]</span></p>

<p><strong>解释:</strong></p>

<p><img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2900-2999/2956.Find%20Common%20Elements%20Between%20Two%20Arrays/images/3488_find_common_elements_between_two_arrays-t1.gif" style="width: 225px; height: 150px;" /></p>
</div>

<p><strong class="example">示例 2:</strong></p>

<pre>
<b>输入:</b>nums1 = [3,4,2,3], nums2 = [1,5]
<b>输出:</b>[0,0]
<b>解释:</b>两个数组中没有公共元素,所以两个值都为 0 。
</pre>
<div class="example-block">
<p><strong>输入:</strong><span class="example-io">nums1 = [4,3,2,3,1], nums2 = [2,2,5,2,3,6]</span></p>

<p><strong>输出:</strong><span class="example-io">[3,4]</span></p>

<p><strong>解释:</strong></p>

<p><code>nums1</code>&nbsp;中下标在 1,2,3 的元素在&nbsp;<code>nums2</code>&nbsp;中也存在。所以&nbsp;<code>answer1</code>&nbsp;&nbsp;3。</p>

<p><code>nums2</code>&nbsp;中下标在 0,1,3,4 的元素在&nbsp;<code>nums1</code>&nbsp;中也存在。所以&nbsp;<code>answer2</code>&nbsp;为 4。</p>
</div>

<p><strong class="example">示例 3:</strong></p>

<div class="example-block">
<p><strong>输入:</strong><span class="example-io">nums1 = [3,4,2,3], nums2 = [1,5]</span></p>

<p><strong>输出:</strong><span class="example-io">[0,0]</span></p>

<p><strong>解释:</strong></p>

<p><code>nums1</code>&nbsp;&nbsp;<code>nums2</code>&nbsp;中没有相同的数字,所以答案是 [0,0]。</p>
</div>

<p>&nbsp;</p>

Expand Down
Loading
Loading