mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
update
This commit is contained in:
parent
193158abb0
commit
5f3c3f620f
@ -1,6 +1,6 @@
|
||||
# 力扣题库(完整版)
|
||||
|
||||
> 最后更新日期: **2022.10.26**
|
||||
> 最后更新日期: **2022.11.01**
|
||||
>
|
||||
> 使用脚本前请务必仔细完整阅读本 `README.md` 文件
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
165
leetcode-cn/originData/next-greater-element-iv.json
Normal file
165
leetcode-cn/originData/next-greater-element-iv.json
Normal file
File diff suppressed because one or more lines are too long
165
leetcode-cn/originData/words-within-two-edits-of-dictionary.json
Normal file
165
leetcode-cn/originData/words-within-two-edits-of-dictionary.json
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,51 @@
|
||||
<p>给你一个下标从 <strong>0</strong> 开始的非负整数数组 <code>nums</code> 。对于 <code>nums</code> 中每一个整数,你必须找到对应元素的 <strong>第二大</strong> 整数。</p>
|
||||
|
||||
<p>如果 <code>nums[j]</code> 满足以下条件,那么我们称它为 <code>nums[i]</code> 的 <strong>第二大</strong> 整数:</p>
|
||||
|
||||
<ul>
|
||||
<li><code>j > i</code></li>
|
||||
<li><code>nums[j] > nums[i]</code></li>
|
||||
<li>恰好存在 <strong>一个</strong> <code>k</code> 满足 <code>i < k < j</code> 且 <code>nums[k] > nums[i]</code> 。</li>
|
||||
</ul>
|
||||
|
||||
<p>如果不存在 <code>nums[j]</code> ,那么第二大整数为 <code>-1</code> 。</p>
|
||||
|
||||
<ul>
|
||||
<li>比方说,数组 <code>[1, 2, 4, 3]</code> 中,<code>1</code> 的第二大整数是 <code>4</code> ,<code>2</code> 的第二大整数是 <code>3</code> ,<code>3</code> 和 <code>4</code> 的第二大整数是 <code>-1</code> 。</li>
|
||||
</ul>
|
||||
|
||||
<p>请你返回一个整数数组<em> </em><code>answer</code> ,其中<em> </em><code>answer[i]</code>是<em> </em><code>nums[i]</code> 的第二大整数。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<b>输入:</b>nums = [2,4,0,9,6]
|
||||
<b>输出:</b>[9,6,6,-1,-1]
|
||||
<strong>解释:</strong>
|
||||
下标为 0 处:2 的右边,4 是大于 2 的第一个整数,9 是第二个大于 2 的整数。
|
||||
下标为 1 处:4 的右边,9 是大于 4 的第一个整数,6 是第二个大于 4 的整数。
|
||||
下标为 2 处:0 的右边,9 是大于 0 的第一个整数,6 是第二个大于 0 的整数。
|
||||
下标为 3 处:右边不存在大于 9 的整数,所以第二大整数为 -1 。
|
||||
下标为 4 处:右边不存在大于 6 的整数,所以第二大整数为 -1 。
|
||||
所以我们返回 [9,6,6,-1,-1] 。
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>nums = [3,3]
|
||||
<b>输出:</b>[-1,-1]
|
||||
<strong>解释:</strong>
|
||||
由于每个数右边都没有更大的数,所以我们返回 [-1,-1] 。
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
|
||||
<li><code>0 <= nums[i] <= 10<sup>9</sup></code></li>
|
||||
</ul>
|
@ -0,0 +1,39 @@
|
||||
<p>给你两个字符串数组 <code>queries</code> 和 <code>dictionary</code> 。数组中所有单词都只包含小写英文字母,且长度都相同。</p>
|
||||
|
||||
<p>一次 <strong>编辑</strong> 中,你可以从 <code>queries</code> 中选择一个单词,将任意一个字母修改成任何其他字母。从 <code>queries</code> 中找到所有满足以下条件的字符串:<strong>不超过</strong> 两次编辑内,字符串与 <code>dictionary</code> 中某个字符串相同。</p>
|
||||
|
||||
<p>请你返回<em> </em><code>queries</code> 中的单词列表,这些单词距离 <code>dictionary</code> 中的单词 <strong>编辑次数</strong> 不超过 <strong>两次</strong> 。单词返回的顺序需要与 <code>queries</code> 中原本顺序相同。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre><b>输入:</b>queries = ["word","note","ants","wood"], dictionary = ["wood","joke","moat"]
|
||||
<b>输出:</b>["word","note","wood"]
|
||||
<strong>解释:</strong>
|
||||
- 将 "word" 中的 'r' 换成 'o' ,得到 dictionary 中的单词 "wood" 。
|
||||
- 将 "note" 中的 'n' 换成 'j' 且将 't' 换成 'k' ,得到 "joke" 。
|
||||
- "ants" 需要超过 2 次编辑才能得到 dictionary 中的单词。
|
||||
- "wood" 不需要修改(0 次编辑),就得到 dictionary 中相同的单词。
|
||||
所以我们返回 ["word","note","wood"] 。
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre><b>输入:</b>queries = ["yes"], dictionary = ["not"]
|
||||
<b>输出:</b>[]
|
||||
<strong>解释:</strong>
|
||||
"yes" 需要超过 2 次编辑才能得到 "not" 。
|
||||
所以我们返回空数组。
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= queries.length, dictionary.length <= 100</code></li>
|
||||
<li><code>n == queries[i].length == dictionary[j].length</code></li>
|
||||
<li><code>1 <= n <= 100</code></li>
|
||||
<li>所有 <code>queries[i]</code> 和 <code>dictionary[j]</code> 都只包含小写英文字母。</li>
|
||||
</ul>
|
@ -0,0 +1,49 @@
|
||||
<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>
|
||||
|
||||
<p>The <strong>second greater</strong> integer of <code>nums[i]</code> is <code>nums[j]</code> such that:</p>
|
||||
|
||||
<ul>
|
||||
<li><code>j > i</code></li>
|
||||
<li><code>nums[j] > nums[i]</code></li>
|
||||
<li>There exists <strong>exactly one</strong> index <code>k</code> such that <code>nums[k] > nums[i]</code> and <code>i < k < j</code>.</li>
|
||||
</ul>
|
||||
|
||||
<p>If there is no such <code>nums[j]</code>, the second greater integer is considered to be <code>-1</code>.</p>
|
||||
|
||||
<ul>
|
||||
<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>, and that of <code>3</code> and <code>4</code> is <code>-1</code>.</li>
|
||||
</ul>
|
||||
|
||||
<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>
|
||||
|
||||
<p> </p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> nums = [2,4,0,9,6]
|
||||
<strong>Output:</strong> [9,6,6,-1,-1]
|
||||
<strong>Explanation:</strong>
|
||||
0th index: 4 is the first integer greater than 2, and 9 is the second integer greater than 2, to the right of 2.
|
||||
1st index: 9 is the first, and 6 is the second integer greater than 4, to the right of 4.
|
||||
2nd index: 9 is the first, and 6 is the second integer greater than 0, to the right of 0.
|
||||
3rd index: There is no integer greater than 9 to its right, so the second greater integer is considered to be -1.
|
||||
4th index: There is no integer greater than 6 to its right, so the second greater integer is considered to be -1.
|
||||
Thus, we return [9,6,6,-1,-1].
|
||||
</pre>
|
||||
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> nums = [3,3]
|
||||
<strong>Output:</strong> [-1,-1]
|
||||
<strong>Explanation:</strong>
|
||||
We return [-1,-1] since neither integer has any integer greater than it.
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
|
||||
<li><code>0 <= nums[i] <= 10<sup>9</sup></code></li>
|
||||
</ul>
|
@ -0,0 +1,38 @@
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
<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>
|
||||
|
||||
<p> </p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> queries = ["word","note","ants","wood"], dictionary = ["wood","joke","moat"]
|
||||
<strong>Output:</strong> ["word","note","wood"]
|
||||
<strong>Explanation:</strong>
|
||||
- Changing the 'r' in "word" to 'o' allows it to equal the dictionary word "wood".
|
||||
- Changing the 'n' to 'j' and the 't' to 'k' in "note" changes it to "joke".
|
||||
- It would take more than 2 edits for "ants" to equal a dictionary word.
|
||||
- "wood" can remain unchanged (0 edits) and match the corresponding dictionary word.
|
||||
Thus, we return ["word","note","wood"].
|
||||
</pre>
|
||||
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> queries = ["yes"], dictionary = ["not"]
|
||||
<strong>Output:</strong> []
|
||||
<strong>Explanation:</strong>
|
||||
Applying any two edits to "yes" cannot make it equal to "not". Thus, we return an empty array.
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= queries.length, dictionary.length <= 100</code></li>
|
||||
<li><code>n == queries[i].length == dictionary[j].length</code></li>
|
||||
<li><code>1 <= n <= 100</code></li>
|
||||
<li>All <code>queries[i]</code> and <code>dictionary[j]</code> are composed of lowercase English letters.</li>
|
||||
</ul>
|
Loading…
Reference in New Issue
Block a user