Skip to content

Commit 5f3c3f6

Browse files
committed
update
1 parent 193158a commit 5f3c3f6

8 files changed

+7871
-7175
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 力扣题库(完整版)
22

3-
> 最后更新日期: **2022.10.26**
3+
> 最后更新日期: **2022.11.01**
44
>
55
> 使用脚本前请务必仔细完整阅读本 `README.md` 文件
66

leetcode-cn/origin-data.json

+7,363-7,174
Large diffs are not rendered by default.

leetcode-cn/originData/next-greater-element-iv.json

+165
Large diffs are not rendered by default.

leetcode-cn/originData/words-within-two-edits-of-dictionary.json

+165
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<p>给你一个下标从 <strong>0</strong>&nbsp;开始的非负整数数组&nbsp;<code>nums</code>&nbsp;。对于&nbsp;<code>nums</code>&nbsp;中每一个整数,你必须找到对应元素的&nbsp;<strong>第二大</strong>&nbsp;整数。</p>
2+
3+
<p>如果&nbsp;<code>nums[j]</code>&nbsp;满足以下条件,那么我们称它为&nbsp;<code>nums[i]</code>&nbsp;的&nbsp;<strong>第二大</strong>&nbsp;整数:</p>
4+
5+
<ul>
6+
<li><code>j &gt; i</code></li>
7+
<li><code>nums[j] &gt; nums[i]</code></li>
8+
<li>恰好存在 <strong>一个</strong>&nbsp;<code>k</code>&nbsp;满足 <code>i &lt; k &lt; j</code>&nbsp;且&nbsp;<code>nums[k] &gt; nums[i]</code>&nbsp;。</li>
9+
</ul>
10+
11+
<p>如果不存在&nbsp;<code>nums[j]</code>&nbsp;,那么第二大整数为&nbsp;<code>-1</code>&nbsp;。</p>
12+
13+
<ul>
14+
<li>比方说,数组&nbsp;<code>[1, 2, 4, 3]</code>&nbsp;中,<code>1</code>&nbsp;的第二大整数是&nbsp;<code>4</code>&nbsp;,<code>2</code>&nbsp;的第二大整数是&nbsp;<code>3</code>&nbsp;,<code>3</code> 和&nbsp;<code>4</code>&nbsp;的第二大整数是&nbsp;<code>-1</code>&nbsp;。</li>
15+
</ul>
16+
17+
<p>请你返回一个整数数组<em>&nbsp;</em><code>answer</code>&nbsp;,其中<em>&nbsp;</em><code>answer[i]</code><em>&nbsp;</em><code>nums[i]</code>&nbsp;的第二大整数。</p>
18+
19+
<p>&nbsp;</p>
20+
21+
<p><strong>示例 1:</strong></p>
22+
23+
<pre>
24+
<b>输入:</b>nums = [2,4,0,9,6]
25+
<b>输出:</b>[9,6,6,-1,-1]
26+
<strong>解释:</strong>
27+
下标为 0 处:2 的右边,4 是大于 2 的第一个整数,9 是第二个大于 2 的整数。
28+
下标为 1 处:4 的右边,9 是大于 4 的第一个整数,6 是第二个大于 4 的整数。
29+
下标为 2 处:0 的右边,9 是大于 0 的第一个整数,6 是第二个大于 0 的整数。
30+
下标为 3 处:右边不存在大于 9 的整数,所以第二大整数为 -1 。
31+
下标为 4 处:右边不存在大于 6 的整数,所以第二大整数为 -1 。
32+
所以我们返回 [9,6,6,-1,-1] 。
33+
</pre>
34+
35+
<p><strong>示例 2:</strong></p>
36+
37+
<pre>
38+
<strong>输入:</strong>nums = [3,3]
39+
<b>输出:</b>[-1,-1]
40+
<strong>解释:</strong>
41+
由于每个数右边都没有更大的数,所以我们返回 [-1,-1] 。
42+
</pre>
43+
44+
<p>&nbsp;</p>
45+
46+
<p><strong>提示:</strong></p>
47+
48+
<ul>
49+
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
50+
<li><code>0 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
51+
</ul>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<p>给你两个字符串数组&nbsp;<code>queries</code> 和&nbsp;<code>dictionary</code>&nbsp;。数组中所有单词都只包含小写英文字母,且长度都相同。</p>
2+
3+
<p>一次 <strong>编辑</strong>&nbsp;中,你可以从 <code>queries</code>&nbsp;中选择一个单词,将任意一个字母修改成任何其他字母。从&nbsp;<code>queries</code>&nbsp;中找到所有满足以下条件的字符串:<strong>不超过</strong>&nbsp;两次编辑内,字符串与&nbsp;<code>dictionary</code>&nbsp;中某个字符串相同。</p>
4+
5+
<p>请你返回<em>&nbsp;</em><code>queries</code>&nbsp;中的单词列表,这些单词距离&nbsp;<code>dictionary</code>&nbsp;中的单词&nbsp;<strong>编辑次数</strong>&nbsp;不超过&nbsp;<strong>两次</strong>&nbsp;。单词返回的顺序需要与&nbsp;<code>queries</code>&nbsp;中原本顺序相同。</p>
6+
7+
<p>&nbsp;</p>
8+
9+
<p><strong>示例 1:</strong></p>
10+
11+
<pre><b>输入:</b>queries = ["word","note","ants","wood"], dictionary = ["wood","joke","moat"]
12+
<b>输出:</b>["word","note","wood"]
13+
<strong>解释:</strong>
14+
- 将 "word" 中的 'r' 换成 'o' ,得到 dictionary 中的单词 "wood" 。
15+
- 将 "note" 中的 'n' 换成 'j' 且将 't' 换成 'k' ,得到 "joke" 。
16+
- "ants" 需要超过 2 次编辑才能得到 dictionary 中的单词。
17+
- "wood" 不需要修改(0 次编辑),就得到 dictionary 中相同的单词。
18+
所以我们返回 ["word","note","wood"] 。
19+
</pre>
20+
21+
<p><strong>示例 2:</strong></p>
22+
23+
<pre><b>输入:</b>queries = ["yes"], dictionary = ["not"]
24+
<b>输出:</b>[]
25+
<strong>解释:</strong>
26+
"yes" 需要超过 2 次编辑才能得到 "not" 。
27+
所以我们返回空数组。
28+
</pre>
29+
30+
<p>&nbsp;</p>
31+
32+
<p><strong>提示:</strong></p>
33+
34+
<ul>
35+
<li><code>1 &lt;= queries.length, dictionary.length &lt;= 100</code></li>
36+
<li><code>n == queries[i].length == dictionary[j].length</code></li>
37+
<li><code>1 &lt;= n &lt;= 100</code></li>
38+
<li>所有&nbsp;<code>queries[i]</code> 和&nbsp;<code>dictionary[j]</code>&nbsp;都只包含小写英文字母。</li>
39+
</ul>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<p>You are given a <strong>0-indexed</strong> array of non-negative integers <code>nums</code>. For each integer in <code>nums</code>, you must find its respective <strong>second greater</strong> integer.</p>
2+
3+
<p>The <strong>second greater</strong> integer of <code>nums[i]</code> is <code>nums[j]</code> such that:</p>
4+
5+
<ul>
6+
<li><code>j &gt; i</code></li>
7+
<li><code>nums[j] &gt; nums[i]</code></li>
8+
<li>There exists <strong>exactly one</strong> index <code>k</code> such that <code>nums[k] &gt; nums[i]</code> and <code>i &lt; k &lt; j</code>.</li>
9+
</ul>
10+
11+
<p>If there is no such <code>nums[j]</code>, the second greater integer is considered to be <code>-1</code>.</p>
12+
13+
<ul>
14+
<li>For example, in the array <code>[1, 2, 4, 3]</code>, the second greater integer of <code>1</code> is <code>4</code>, <code>2</code> is <code>3</code>,&nbsp;and that of <code>3</code> and <code>4</code> is <code>-1</code>.</li>
15+
</ul>
16+
17+
<p>Return<em> an integer array </em><code>answer</code><em>, where </em><code>answer[i]</code><em> is the second greater integer of </em><code>nums[i]</code><em>.</em></p>
18+
19+
<p>&nbsp;</p>
20+
<p><strong class="example">Example 1:</strong></p>
21+
22+
<pre>
23+
<strong>Input:</strong> nums = [2,4,0,9,6]
24+
<strong>Output:</strong> [9,6,6,-1,-1]
25+
<strong>Explanation:</strong>
26+
0th index: 4 is the first integer greater than 2, and 9 is the second integer greater than 2, to the right of 2.
27+
1st index: 9 is the first, and 6 is the second integer greater than 4, to the right of 4.
28+
2nd index: 9 is the first, and 6 is the second integer greater than 0, to the right of 0.
29+
3rd index: There is no integer greater than 9 to its right, so the second greater integer is considered to be -1.
30+
4th index: There is no integer greater than 6 to its right, so the second greater integer is considered to be -1.
31+
Thus, we return [9,6,6,-1,-1].
32+
</pre>
33+
34+
<p><strong class="example">Example 2:</strong></p>
35+
36+
<pre>
37+
<strong>Input:</strong> nums = [3,3]
38+
<strong>Output:</strong> [-1,-1]
39+
<strong>Explanation:</strong>
40+
We return [-1,-1] since neither integer has any integer greater than it.
41+
</pre>
42+
43+
<p>&nbsp;</p>
44+
<p><strong>Constraints:</strong></p>
45+
46+
<ul>
47+
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
48+
<li><code>0 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
49+
</ul>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<p>You are given two string arrays, <code>queries</code> and <code>dictionary</code>. All words in each array comprise of lowercase English letters and have the same length.</p>
2+
3+
<p>In one <strong>edit</strong> you can take a word from <code>queries</code>, and change any letter in it to any other letter. Find all words from <code>queries</code> that, after a <strong>maximum</strong> of two edits, equal some word from <code>dictionary</code>.</p>
4+
5+
<p>Return<em> a list of all words from </em><code>queries</code><em>, </em><em>that match with some word from </em><code>dictionary</code><em> after a maximum of <strong>two edits</strong></em>. Return the words in the <strong>same order</strong> they appear in <code>queries</code>.</p>
6+
7+
<p>&nbsp;</p>
8+
<p><strong class="example">Example 1:</strong></p>
9+
10+
<pre>
11+
<strong>Input:</strong> queries = [&quot;word&quot;,&quot;note&quot;,&quot;ants&quot;,&quot;wood&quot;], dictionary = [&quot;wood&quot;,&quot;joke&quot;,&quot;moat&quot;]
12+
<strong>Output:</strong> [&quot;word&quot;,&quot;note&quot;,&quot;wood&quot;]
13+
<strong>Explanation:</strong>
14+
- Changing the &#39;r&#39; in &quot;word&quot; to &#39;o&#39; allows it to equal the dictionary word &quot;wood&quot;.
15+
- Changing the &#39;n&#39; to &#39;j&#39; and the &#39;t&#39; to &#39;k&#39; in &quot;note&quot; changes it to &quot;joke&quot;.
16+
- It would take more than 2 edits for &quot;ants&quot; to equal a dictionary word.
17+
- &quot;wood&quot; can remain unchanged (0 edits) and match the corresponding dictionary word.
18+
Thus, we return [&quot;word&quot;,&quot;note&quot;,&quot;wood&quot;].
19+
</pre>
20+
21+
<p><strong class="example">Example 2:</strong></p>
22+
23+
<pre>
24+
<strong>Input:</strong> queries = [&quot;yes&quot;], dictionary = [&quot;not&quot;]
25+
<strong>Output:</strong> []
26+
<strong>Explanation:</strong>
27+
Applying any two edits to &quot;yes&quot; cannot make it equal to &quot;not&quot;. Thus, we return an empty array.
28+
</pre>
29+
30+
<p>&nbsp;</p>
31+
<p><strong>Constraints:</strong></p>
32+
33+
<ul>
34+
<li><code>1 &lt;= queries.length, dictionary.length &lt;= 100</code></li>
35+
<li><code>n == queries[i].length == dictionary[j].length</code></li>
36+
<li><code>1 &lt;= n &lt;= 100</code></li>
37+
<li>All <code>queries[i]</code> and <code>dictionary[j]</code> are composed of lowercase English letters.</li>
38+
</ul>

0 commit comments

Comments
 (0)