1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
程序员小墨 2022-07-17 17:35:36 +08:00
parent ea34fbb843
commit 86906ca247
27 changed files with 13775 additions and 11552 deletions

View File

@ -1,6 +1,6 @@
# 力扣题库(完整版)
> 最后更新日期: **2022.06.12**
> 最后更新日期: **2022.07.17**
>
> 使用脚本前请务必仔细完整阅读本 `README.md` 文件

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,52 @@
{
"data": {
"question": {
"questionId": "2453",
"questionFrontendId": "2339",
"categoryTitle": "Database",
"boundTopicId": 1668293,
"title": "All the Matches of the League",
"titleSlug": "all-the-matches-of-the-league",
"content": null,
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": true,
"difficulty": "Easy",
"likes": 0,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": null,
"topicTags": [],
"companyTagStats": null,
"codeSnippets": null,
"stats": "{\"totalAccepted\": \"73\", \"totalSubmission\": \"91\", \"totalAcceptedRaw\": 73, \"totalSubmissionRaw\": 91, \"acRate\": \"80.2%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\": {\"Teams\": [\"team_name\"]}, \"rows\": {\"Teams\": [[\"Leetcode FC\"], [\"Ahly SC\"], [\"Real Madrid\"]]}}",
"metaData": "{\n \"mysql\": [\n \"Create table If Not Exists Teams (team_name varchar(50))\"\n ],\n \"mssql\": [\n \"Create table Teams (team_name varchar(50))\"\n ],\n \"oraclesql\": [\n \"Create table Teams (team_name varchar(50))\"\n ],\n \"database\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"Create table If Not Exists Teams (team_name varchar(50))",
"Truncate table Teams",
"insert into Teams (team_name) values ('Leetcode FC')",
"insert into Teams (team_name) values ('Ahly SC')",
"insert into Teams (team_name) values ('Real Madrid')"
],
"enableRunCode": true,
"envInfo": "{\"mysql\":[\"MySQL\",\"<p>\\u7248\\u672c\\uff1a<code>MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"<p>mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\"<p>Oracle Sql 11.2.<\\/p>\"]}",
"book": null,
"isSubscribed": false,
"isDailyQuestion": false,
"dailyRecordStatus": null,
"editorType": "CKEDITOR",
"ugcQuestionId": null,
"style": "LEETCODE",
"exampleTestcases": "{\"headers\": {\"Teams\": [\"team_name\"]}, \"rows\": {\"Teams\": [[\"Leetcode FC\"], [\"Ahly SC\"], [\"Real Madrid\"]]}}",
"__typename": "QuestionNode"
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,35 @@
<p>给你两个正整数数组&nbsp;<code>nums</code>&nbsp;<code>numsDivide</code>&nbsp;。你可以从&nbsp;<code>nums</code>&nbsp;中删除任意数目的元素。</p>
<p>请你返回使 <code>nums</code>&nbsp;<strong>最小</strong>&nbsp;元素可以整除 <code>numsDivide</code>&nbsp;中所有元素的 <strong>最少</strong>&nbsp;删除次数。如果无法得到这样的元素,返回 <code>-1</code>&nbsp;</p>
<p>如果&nbsp;<code>y % x == 0</code>&nbsp;,那么我们说整数&nbsp;<code>x</code>&nbsp;整除&nbsp;<code>y</code>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><b>输入:</b>nums = [2,3,2,4,3], numsDivide = [9,6,9,3,15]
<b>输出:</b>2
<b>解释:</b>
[2,3,2,4,3] 中最小元素是 2 ,它无法整除 numsDivide 中所有元素。
我们从 nums 中删除 2 个大小为 2 的元素,得到 nums = [3,4,3] 。
[3,4,3] 中最小元素为 3 ,它可以整除 numsDivide 中所有元素。
可以证明 2 是最少删除次数。
</pre>
<p><strong>示例 2</strong></p>
<pre><b>输入:</b>nums = [4,3,6], numsDivide = [8,2,6,10]
<b>输出:</b>-1
<b>解释:</b>
我们想 nums 中的最小元素可以整除 numsDivide 中的所有元素。
没有任何办法可以达到这一目的。</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length, numsDivide.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i], numsDivide[i] &lt;= 10<sup>9</sup></code></li>
</ul>

View File

@ -0,0 +1,32 @@
<p>给你一个下标从 <strong>0</strong> 开始的数组 <code>nums</code> ,数组中的元素都是 <strong></strong> 整数。请你选出两个下标 <code>i</code><code>j</code><code>i != j</code>),且 <code>nums[i]</code> 的数位和 与&nbsp; <code>nums[j]</code> 的数位和相等。</p>
<p>请你找出所有满足条件的下标 <code>i</code><code>j</code> ,找出并返回<em> </em><code>nums[i] + nums[j]</code><em> </em>可以得到的 <strong>最大值</strong> <em></em></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [18,43,36,13,7]
<strong>输出:</strong>54
<strong>解释:</strong>满足条件的数对 (i, j) 为:
- (0, 2) ,两个数字的数位和都是 9 ,相加得到 18 + 36 = 54 。
- (1, 4) ,两个数字的数位和都是 7 ,相加得到 43 + 7 = 50 。
所以可以获得的最大和是 54 。</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>nums = [10,12,19,14]
<strong>输出:</strong>-1
<strong>解释:</strong>不存在满足条件的数对,返回 -1 。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
</ul>

View File

@ -0,0 +1,45 @@
<p>给你一个下标从 <strong>0</strong> 开始的整数数组 <code>nums</code> 。在一步操作中,你可以执行以下步骤:</p>
<ul>
<li><code>nums</code> 选出 <strong>两个</strong> <strong>相等的</strong> 整数</li>
<li><code>nums</code> 中移除这两个整数,形成一个 <strong>数对</strong></li>
</ul>
<p>请你在 <code>nums</code> 上多次执行此操作直到无法继续执行。</p>
<p>返回一个下标从 <strong>0</strong> 开始、长度为 <code>2</code> 的整数数组 <code>answer</code> 作为答案,其中<em> </em><code>answer[0]</code><em> </em>是形成的数对数目,<code>answer[1]</code> 是对 <code>nums</code> 尽可能执行上述操作后剩下的整数数目。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre><strong>输入:</strong>nums = [1,3,2,1,3,2,2]
<strong>输出:</strong>[3,1]
<strong>解释:</strong>
nums[0] 和 nums[3] 形成一个数对,并从 nums 中移除nums = [3,2,3,2,2] 。
nums[0] 和 nums[2] 形成一个数对,并从 nums 中移除nums = [2,2,2] 。
nums[0] 和 nums[1] 形成一个数对,并从 nums 中移除nums = [2] 。
无法形成更多数对。总共形成 3 个数对nums 中剩下 1 个数字。</pre>
<p><strong>示例 2</strong></p>
<pre><strong>输入:</strong>nums = [1,1]
<strong>输出:</strong>[1,0]
<strong>解释:</strong>nums[0] 和 nums[1] 形成一个数对,并从 nums 中移除nums = [] 。
无法形成更多数对。总共形成 1 个数对nums 中剩下 0 个数字。</pre>
<p><strong>示例 3</strong></p>
<pre><strong>输入:</strong>nums = [0]
<strong>输出:</strong>[0,1]
<strong>解释:</strong>无法形成数对nums 中剩下 1 个数字。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 100</code></li>
<li><code>0 &lt;= nums[i] &lt;= 100</code></li>
</ul>

View File

@ -0,0 +1,59 @@
<p>给你一个下标从 <strong>0</strong>&nbsp;开始的字符串数组&nbsp;<code>nums</code>&nbsp;,其中每个字符串 <strong>长度相等</strong>&nbsp;且只包含数字。</p>
<p>再给你一个下标从 <strong>0</strong>&nbsp;开始的二维整数数组&nbsp;<code>queries</code>&nbsp;,其中&nbsp;<code>queries[i] = [k<sub>i</sub>, trim<sub>i</sub>]</code>&nbsp;。对于每个&nbsp;<code>queries[i]</code>&nbsp;,你需要:</p>
<ul>
<li>&nbsp;<code>nums</code>&nbsp;中每个数字 <strong>裁剪</strong>&nbsp;到剩下 <strong>最右边</strong>&nbsp;<code>trim<sub>i</sub></code>&nbsp;个数位。</li>
<li>在裁剪过后的数字中,找到 <code>nums</code>&nbsp;中第&nbsp;<code>k<sub>i</sub></code>&nbsp;小数字对应的 <strong>下标</strong>&nbsp;。如果两个裁剪后数字一样大,那么下标 <strong>更小</strong>&nbsp;的数字视为更小的数字。</li>
<li><code>nums</code>&nbsp;中每个数字恢复到原本字符串。</li>
</ul>
<p>请你返回一个长度与 <code><span style="">queries</span></code>&nbsp;相等的数组<em>&nbsp;</em><code>answer</code>,其中<em>&nbsp;</em><code>answer[i]</code>是第<em>&nbsp;</em><code>i</code><em>&nbsp;</em>次查询的结果。</p>
<p><strong>提示:</strong></p>
<ul>
<li>裁剪到剩下 <code>x</code>&nbsp;个数位的意思是不断删除最左边的数位,直到剩下 <code>x</code>&nbsp;个数位。</li>
<li><code>nums</code>&nbsp;中的字符串可能会有前导 0 。</li>
</ul>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<b>输入:</b>nums = ["102","473","251","814"], queries = [[1,1],[2,3],[4,2],[1,2]]
<b>输出:</b>[2,2,1,0]
<strong>解释:</strong>
1. 裁剪到只剩 1 个数位后nums = ["2","3","1","4"] 。最小的数字是 1 ,下标为 2 。
2. 裁剪到剩 3 个数位后nums 没有变化。第 2 小的数字是 251 ,下标为 2 。
3. 裁剪到剩 2 个数位后nums = ["02","73","51","14"] 。第 4 小的数字是 73 ,下标为 1 。
4. 裁剪到剩 2 个数位后,最小数字是 2 ,下标为 0 。
注意,裁剪后数字 "02" 值为 2 。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<b>输入:</b>nums = ["24","37","96","04"], queries = [[2,1],[2,2]]
<b>输出:</b>[3,0]
<strong>解释:</strong>
1. 裁剪到剩 1 个数位nums = ["4","7","6","4"] 。第 2 小的数字是 4 ,下标为 3 。
有两个 4 ,下标为 0 的 4 视为小于下标为 3 的 4 。
2. 裁剪到剩 2 个数位nums 不变。第二小的数字是 24 ,下标为 0 。
</pre>
<p>&nbsp;</p>
<p><b>提示:</b></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 100</code></li>
<li><code>1 &lt;= nums[i].length &lt;= 100</code></li>
<li><code>nums[i]</code> 只包含数字。</li>
<li>所有&nbsp;<code>nums[i].length</code>&nbsp;的长度 <b>相同</b>&nbsp;</li>
<li><code>1 &lt;= queries.length &lt;= 100</code></li>
<li><code>queries[i].length == 2</code></li>
<li><code>1 &lt;= k<sub>i</sub> &lt;= nums.length</code></li>
<li><code>1 &lt;= trim<sub>i</sub> &lt;= nums[0].length</code></li>
</ul>

View File

@ -0,0 +1,35 @@
<p>You are given two positive integer arrays <code>nums</code> and <code>numsDivide</code>. You can delete any number of elements from <code>nums</code>.</p>
<p>Return <em>the <strong>minimum</strong> number of deletions such that the <strong>smallest</strong> element in </em><code>nums</code><em> <strong>divides</strong> all the elements of </em><code>numsDivide</code>. If this is not possible, return <code>-1</code>.</p>
<p>Note that an integer <code>x</code> divides <code>y</code> if <code>y % x == 0</code>.</p>
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [2,3,2,4,3], numsDivide = [9,6,9,3,15]
<strong>Output:</strong> 2
<strong>Explanation:</strong>
The smallest element in [2,3,2,4,3] is 2, which does not divide all the elements of numsDivide.
We use 2 deletions to delete the elements in nums that are equal to 2 which makes nums = [3,4,3].
The smallest element in [3,4,3] is 3, which divides all the elements of numsDivide.
It can be shown that 2 is the minimum number of deletions needed.
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [4,3,6], numsDivide = [8,2,6,10]
<strong>Output:</strong> -1
<strong>Explanation:</strong>
We want the smallest element in nums to divide all the elements of numsDivide.
There is no way to delete elements from nums to allow this.</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= nums.length, numsDivide.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i], numsDivide[i] &lt;= 10<sup>9</sup></code></li>
</ul>

View File

@ -0,0 +1,31 @@
<p>You are given a <strong>0-indexed</strong> array <code>nums</code> consisting of <strong>positive</strong> integers. You can choose two indices <code>i</code> and <code>j</code>, such that <code>i != j</code>, and the sum of digits of the number <code>nums[i]</code> is equal to that of <code>nums[j]</code>.</p>
<p>Return <em>the <strong>maximum</strong> value of </em><code>nums[i] + nums[j]</code><em> that you can obtain over all possible indices </em><code>i</code><em> and </em><code>j</code><em> that satisfy the conditions.</em></p>
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [18,43,36,13,7]
<strong>Output:</strong> 54
<strong>Explanation:</strong> The pairs (i, j) that satisfy the conditions are:
- (0, 2), both numbers have a sum of digits equal to 9, and their sum is 18 + 36 = 54.
- (1, 4), both numbers have a sum of digits equal to 7, and their sum is 43 + 7 = 50.
So the maximum sum that we can obtain is 54.
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [10,12,19,14]
<strong>Output:</strong> -1
<strong>Explanation:</strong> There are no two numbers that satisfy the conditions, so we return -1.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
</ul>

View File

@ -0,0 +1,48 @@
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. In one operation, you may do the following:</p>
<ul>
<li>Choose <strong>two</strong> integers in <code>nums</code> that are <strong>equal</strong>.</li>
<li>Remove both integers from <code>nums</code>, forming a <strong>pair</strong>.</li>
</ul>
<p>The operation is done on <code>nums</code> as many times as possible.</p>
<p>Return <em>a <strong>0-indexed</strong> integer array </em><code>answer</code><em> of size </em><code>2</code><em> where </em><code>answer[0]</code><em> is the number of pairs that are formed and </em><code>answer[1]</code><em> is the number of leftover integers in </em><code>nums</code><em> after doing the operation as many times as possible</em>.</p>
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [1,3,2,1,3,2,2]
<strong>Output:</strong> [3,1]
<strong>Explanation:</strong>
Form a pair with nums[0] and nums[3] and remove them from nums. Now, nums = [3,2,3,2,2].
Form a pair with nums[0] and nums[2] and remove them from nums. Now, nums = [2,2,2].
Form a pair with nums[0] and nums[1] and remove them from nums. Now, nums = [2].
No more pairs can be formed. A total of 3 pairs have been formed, and there is 1 number leftover in nums.
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [1,1]
<strong>Output:</strong> [1,0]
<strong>Explanation:</strong> Form a pair with nums[0] and nums[1] and remove them from nums. Now, nums = [].
No more pairs can be formed. A total of 1 pair has been formed, and there are 0 numbers leftover in nums.
</pre>
<p><strong>Example 3:</strong></p>
<pre>
<strong>Input:</strong> nums = [0]
<strong>Output:</strong> [0,1]
<strong>Explanation:</strong> No pairs can be formed, and there is 1 number leftover in nums.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 100</code></li>
<li><code>0 &lt;= nums[i] &lt;= 100</code></li>
</ul>

View File

@ -0,0 +1,57 @@
<p>You are given a <strong>0-indexed</strong> array of strings <code>nums</code>, where each string is of <strong>equal length</strong> and consists of only digits.</p>
<p>You are also given a <strong>0-indexed</strong> 2D integer array <code>queries</code> where <code>queries[i] = [k<sub>i</sub>, trim<sub>i</sub>]</code>. For each <code>queries[i]</code>, you need to:</p>
<ul>
<li><strong>Trim</strong> each number in <code>nums</code> to its <strong>rightmost</strong> <code>trim<sub>i</sub></code> digits.</li>
<li>Determine the <strong>index</strong> of the <code>k<sub>i</sub><sup>th</sup></code> smallest trimmed number in <code>nums</code>. If two trimmed numbers are equal, the number with the <strong>lower</strong> index is considered to be smaller.</li>
<li>Reset each number in <code>nums</code> to its original length.</li>
</ul>
<p>Return <em>an array </em><code>answer</code><em> of the same length as </em><code>queries</code>,<em> where </em><code>answer[i]</code><em> is the answer to the </em><code>i<sup>th</sup></code><em> query.</em></p>
<p><strong>Note</strong>:</p>
<ul>
<li>To trim to the rightmost <code>x</code> digits means to keep removing the leftmost digit, until only <code>x</code> digits remain.</li>
<li>Strings in <code>nums</code> may contain leading zeros.</li>
</ul>
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [&quot;102&quot;,&quot;473&quot;,&quot;251&quot;,&quot;814&quot;], queries = [[1,1],[2,3],[4,2],[1,2]]
<strong>Output:</strong> [2,2,1,0]
<strong>Explanation:</strong>
1. After trimming to the last digit, nums = [&quot;2&quot;,&quot;3&quot;,&quot;1&quot;,&quot;4&quot;]. The smallest number is 1 at index 2.
2. Trimmed to the last 3 digits, nums is unchanged. The 2<sup>nd</sup> smallest number is 251 at index 2.
3. Trimmed to the last 2 digits, nums = [&quot;02&quot;,&quot;73&quot;,&quot;51&quot;,&quot;14&quot;]. The 4<sup>th</sup> smallest number is 73.
4. Trimmed to the last 2 digits, the smallest number is 2 at index 0.
Note that the trimmed number &quot;02&quot; is evaluated as 2.
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [&quot;24&quot;,&quot;37&quot;,&quot;96&quot;,&quot;04&quot;], queries = [[2,1],[2,2]]
<strong>Output:</strong> [3,0]
<strong>Explanation:</strong>
1. Trimmed to the last digit, nums = [&quot;4&quot;,&quot;7&quot;,&quot;6&quot;,&quot;4&quot;]. The 2<sup>nd</sup> smallest number is 4 at index 3.
There are two occurrences of 4, but the one at index 0 is considered smaller than the one at index 3.
2. Trimmed to the last 2 digits, nums is unchanged. The 2<sup>nd</sup> smallest number is 24.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 100</code></li>
<li><code>1 &lt;= nums[i].length &lt;= 100</code></li>
<li><code>nums[i]</code> consists of only digits.</li>
<li>All <code>nums[i].length</code> are <strong>equal</strong>.</li>
<li><code>1 &lt;= queries.length &lt;= 100</code></li>
<li><code>queries[i].length == 2</code></li>
<li><code>1 &lt;= k<sub>i</sub> &lt;= nums.length</code></li>
<li><code>1 &lt;= trim<sub>i</sub> &lt;= nums[i].length</code></li>
</ul>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,49 @@
{
"data": {
"question": {
"questionId": "2453",
"questionFrontendId": "2339",
"boundTopicId": null,
"title": "All the Matches of the League",
"titleSlug": "all-the-matches-of-the-league",
"content": null,
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": true,
"difficulty": "Easy",
"likes": 7,
"dislikes": 1,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": "{\"headers\": {\"Teams\": [\"team_name\"]}, \"rows\": {\"Teams\": [[\"Leetcode FC\"], [\"Ahly SC\"], [\"Real Madrid\"]]}}",
"categoryTitle": "Database",
"contributors": [],
"topicTags": [],
"companyTagStats": null,
"codeSnippets": null,
"stats": "{\"totalAccepted\": \"276\", \"totalSubmission\": \"303\", \"totalAcceptedRaw\": 276, \"totalSubmissionRaw\": 303, \"acRate\": \"91.1%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\": {\"Teams\": [\"team_name\"]}, \"rows\": {\"Teams\": [[\"Leetcode FC\"], [\"Ahly SC\"], [\"Real Madrid\"]]}}",
"metaData": "{\n \"mysql\": [\n \"Create table If Not Exists Teams (team_name varchar(50))\"\n ],\n \"mssql\": [\n \"Create table Teams (team_name varchar(50))\"\n ],\n \"oraclesql\": [\n \"Create table Teams (team_name varchar(50))\"\n ],\n \"database\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"Create table If Not Exists Teams (team_name varchar(50))",
"Truncate table Teams",
"insert into Teams (team_name) values ('Leetcode FC')",
"insert into Teams (team_name) values ('Ahly SC')",
"insert into Teams (team_name) values ('Real Madrid')"
],
"enableRunCode": true,
"enableTestMode": false,
"enableDebugger": false,
"envInfo": "{\"mysql\": [\"MySQL\", \"<p><code>MySQL 8.0</code>.</p>\"], \"mssql\": [\"MS SQL Server\", \"<p><code>mssql server 2019</code>.</p>\"], \"oraclesql\": [\"Oracle\", \"<p><code>Oracle Sql 11.2</code>.</p>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,31 @@
<p>You are given a <strong>0-indexed</strong> array <code>nums</code> consisting of <strong>positive</strong> integers. You can choose two indices <code>i</code> and <code>j</code>, such that <code>i != j</code>, and the sum of digits of the number <code>nums[i]</code> is equal to that of <code>nums[j]</code>.</p>
<p>Return <em>the <strong>maximum</strong> value of </em><code>nums[i] + nums[j]</code><em> that you can obtain over all possible indices </em><code>i</code><em> and </em><code>j</code><em> that satisfy the conditions.</em></p>
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [18,43,36,13,7]
<strong>Output:</strong> 54
<strong>Explanation:</strong> The pairs (i, j) that satisfy the conditions are:
- (0, 2), both numbers have a sum of digits equal to 9, and their sum is 18 + 36 = 54.
- (1, 4), both numbers have a sum of digits equal to 7, and their sum is 43 + 7 = 50.
So the maximum sum that we can obtain is 54.
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [10,12,19,14]
<strong>Output:</strong> -1
<strong>Explanation:</strong> There are no two numbers that satisfy the conditions, so we return -1.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
</ul>

View File

@ -0,0 +1,48 @@
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code>. In one operation, you may do the following:</p>
<ul>
<li>Choose <strong>two</strong> integers in <code>nums</code> that are <strong>equal</strong>.</li>
<li>Remove both integers from <code>nums</code>, forming a <strong>pair</strong>.</li>
</ul>
<p>The operation is done on <code>nums</code> as many times as possible.</p>
<p>Return <em>a <strong>0-indexed</strong> integer array </em><code>answer</code><em> of size </em><code>2</code><em> where </em><code>answer[0]</code><em> is the number of pairs that are formed and </em><code>answer[1]</code><em> is the number of leftover integers in </em><code>nums</code><em> after doing the operation as many times as possible</em>.</p>
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [1,3,2,1,3,2,2]
<strong>Output:</strong> [3,1]
<strong>Explanation:</strong>
Form a pair with nums[0] and nums[3] and remove them from nums. Now, nums = [3,2,3,2,2].
Form a pair with nums[0] and nums[2] and remove them from nums. Now, nums = [2,2,2].
Form a pair with nums[0] and nums[1] and remove them from nums. Now, nums = [2].
No more pairs can be formed. A total of 3 pairs have been formed, and there is 1 number leftover in nums.
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [1,1]
<strong>Output:</strong> [1,0]
<strong>Explanation:</strong> Form a pair with nums[0] and nums[1] and remove them from nums. Now, nums = [].
No more pairs can be formed. A total of 1 pair has been formed, and there are 0 numbers leftover in nums.
</pre>
<p><strong>Example 3:</strong></p>
<pre>
<strong>Input:</strong> nums = [0]
<strong>Output:</strong> [0,1]
<strong>Explanation:</strong> No pairs can be formed, and there is 1 number leftover in nums.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 100</code></li>
<li><code>0 &lt;= nums[i] &lt;= 100</code></li>
</ul>

View File

@ -0,0 +1,35 @@
<p>You are given two positive integer arrays <code>nums</code> and <code>numsDivide</code>. You can delete any number of elements from <code>nums</code>.</p>
<p>Return <em>the <strong>minimum</strong> number of deletions such that the <strong>smallest</strong> element in </em><code>nums</code><em> <strong>divides</strong> all the elements of </em><code>numsDivide</code>. If this is not possible, return <code>-1</code>.</p>
<p>Note that an integer <code>x</code> divides <code>y</code> if <code>y % x == 0</code>.</p>
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [2,3,2,4,3], numsDivide = [9,6,9,3,15]
<strong>Output:</strong> 2
<strong>Explanation:</strong>
The smallest element in [2,3,2,4,3] is 2, which does not divide all the elements of numsDivide.
We use 2 deletions to delete the elements in nums that are equal to 2 which makes nums = [3,4,3].
The smallest element in [3,4,3] is 3, which divides all the elements of numsDivide.
It can be shown that 2 is the minimum number of deletions needed.
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [4,3,6], numsDivide = [8,2,6,10]
<strong>Output:</strong> -1
<strong>Explanation:</strong>
We want the smallest element in nums to divide all the elements of numsDivide.
There is no way to delete elements from nums to allow this.</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= nums.length, numsDivide.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= nums[i], numsDivide[i] &lt;= 10<sup>9</sup></code></li>
</ul>

View File

@ -0,0 +1,57 @@
<p>You are given a <strong>0-indexed</strong> array of strings <code>nums</code>, where each string is of <strong>equal length</strong> and consists of only digits.</p>
<p>You are also given a <strong>0-indexed</strong> 2D integer array <code>queries</code> where <code>queries[i] = [k<sub>i</sub>, trim<sub>i</sub>]</code>. For each <code>queries[i]</code>, you need to:</p>
<ul>
<li><strong>Trim</strong> each number in <code>nums</code> to its <strong>rightmost</strong> <code>trim<sub>i</sub></code> digits.</li>
<li>Determine the <strong>index</strong> of the <code>k<sub>i</sub><sup>th</sup></code> smallest trimmed number in <code>nums</code>. If two trimmed numbers are equal, the number with the <strong>lower</strong> index is considered to be smaller.</li>
<li>Reset each number in <code>nums</code> to its original length.</li>
</ul>
<p>Return <em>an array </em><code>answer</code><em> of the same length as </em><code>queries</code>,<em> where </em><code>answer[i]</code><em> is the answer to the </em><code>i<sup>th</sup></code><em> query.</em></p>
<p><strong>Note</strong>:</p>
<ul>
<li>To trim to the rightmost <code>x</code> digits means to keep removing the leftmost digit, until only <code>x</code> digits remain.</li>
<li>Strings in <code>nums</code> may contain leading zeros.</li>
</ul>
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [&quot;102&quot;,&quot;473&quot;,&quot;251&quot;,&quot;814&quot;], queries = [[1,1],[2,3],[4,2],[1,2]]
<strong>Output:</strong> [2,2,1,0]
<strong>Explanation:</strong>
1. After trimming to the last digit, nums = [&quot;2&quot;,&quot;3&quot;,&quot;1&quot;,&quot;4&quot;]. The smallest number is 1 at index 2.
2. Trimmed to the last 3 digits, nums is unchanged. The 2<sup>nd</sup> smallest number is 251 at index 2.
3. Trimmed to the last 2 digits, nums = [&quot;02&quot;,&quot;73&quot;,&quot;51&quot;,&quot;14&quot;]. The 4<sup>th</sup> smallest number is 73.
4. Trimmed to the last 2 digits, the smallest number is 2 at index 0.
Note that the trimmed number &quot;02&quot; is evaluated as 2.
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [&quot;24&quot;,&quot;37&quot;,&quot;96&quot;,&quot;04&quot;], queries = [[2,1],[2,2]]
<strong>Output:</strong> [3,0]
<strong>Explanation:</strong>
1. Trimmed to the last digit, nums = [&quot;4&quot;,&quot;7&quot;,&quot;6&quot;,&quot;4&quot;]. The 2<sup>nd</sup> smallest number is 4 at index 3.
There are two occurrences of 4, but the one at index 0 is considered smaller than the one at index 3.
2. Trimmed to the last 2 digits, nums is unchanged. The 2<sup>nd</sup> smallest number is 24.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 100</code></li>
<li><code>1 &lt;= nums[i].length &lt;= 100</code></li>
<li><code>nums[i]</code> consists of only digits.</li>
<li>All <code>nums[i].length</code> are <strong>equal</strong>.</li>
<li><code>1 &lt;= queries.length &lt;= 100</code></li>
<li><code>queries[i].length == 2</code></li>
<li><code>1 &lt;= k<sub>i</sub> &lt;= nums.length</code></li>
<li><code>1 &lt;= trim<sub>i</sub> &lt;= nums[i].length</code></li>
</ul>