mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 10:38:13 +08:00
update
This commit is contained in:
parent
952a47471f
commit
e5097bc0f6
@ -1,6 +1,6 @@
|
||||
# 力扣题库(完整版)
|
||||
|
||||
> 最后更新日期: **2023.06.12**
|
||||
> 最后更新日期: **2023.06.22**
|
||||
>
|
||||
> 使用脚本前请务必仔细完整阅读本 `README.md` 文件
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,59 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "2885",
|
||||
"questionFrontendId": "2738",
|
||||
"categoryTitle": "Database",
|
||||
"boundTopicId": 2311776,
|
||||
"title": "Count Occurrences in Text",
|
||||
"titleSlug": "count-occurrences-in-text",
|
||||
"content": null,
|
||||
"translatedTitle": "统计文本中单词的出现次数",
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": true,
|
||||
"difficulty": "Medium",
|
||||
"likes": 0,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"contributors": [],
|
||||
"langToValidPlayground": null,
|
||||
"topicTags": [
|
||||
{
|
||||
"name": "Database",
|
||||
"slug": "database",
|
||||
"translatedName": "数据库",
|
||||
"__typename": "TopicTagNode"
|
||||
}
|
||||
],
|
||||
"companyTagStats": null,
|
||||
"codeSnippets": null,
|
||||
"stats": "{\"totalAccepted\": \"27\", \"totalSubmission\": \"88\", \"totalAcceptedRaw\": 27, \"totalSubmissionRaw\": 88, \"acRate\": \"30.7%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Files\":[\"file_name\",\"content\"]},\"rows\":{\"Files\":[[\"draft1.txt\",\"The stock exchange predicts a bull market which would make many investors happy.\"],[\"draft2.txt\",\"The stock exchange predicts a bull market which would make many investors happy, but analysts warn of possibility of too much optimism and that in fact we are awaiting a bear market.\"],[\"final.txt\",\"The stock exchange predicts a bull market which would make many investors happy, but analysts warn of possibility of too much optimism and that in fact we are awaiting a bear market. As always predicting the future market is an uncertain game and all investors should follow their instincts and best practices.\"]]}}",
|
||||
"metaData": "{\n \"mysql\": [\n \"Create table If Not Exists Files (file_name varchar(100), content text )\"\n ],\n \"mssql\": [\n \"Create table Files (file_name varchar(100), content text )\"\n ],\n \"oraclesql\": [\n \"Create table Files (file_name varchar(100), content clob )\"\n ],\n \"database\": true\n}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Files (file_name varchar(100), content text )",
|
||||
"Truncate table Files",
|
||||
"insert into Files (file_name, content) values ('draft1.txt', 'The stock exchange predicts a bull market which would make many investors happy.')",
|
||||
"insert into Files (file_name, content) values ('draft2.txt', 'The stock exchange predicts a bull market which would make many investors happy, but analysts warn of possibility of too much optimism and that in fact we are awaiting a bear market.')",
|
||||
"insert into Files (file_name, content) values ('final.txt', 'The stock exchange predicts a bull market which would make many investors happy, but analysts warn of possibility of too much optimism and that in fact we are awaiting a bear market. As always predicting the future market is an uncertain game and all investors should follow their instincts and best practices.')"
|
||||
],
|
||||
"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\":{\"Files\":[\"file_name\",\"content\"]},\"rows\":{\"Files\":[[\"draft1.txt\",\"The stock exchange predicts a bull market which would make many investors happy.\"],[\"draft2.txt\",\"The stock exchange predicts a bull market which would make many investors happy, but analysts warn of possibility of too much optimism and that in fact we are awaiting a bear market.\"],[\"final.txt\",\"The stock exchange predicts a bull market which would make many investors happy, but analysts warn of possibility of too much optimism and that in fact we are awaiting a bear market. As always predicting the future market is an uncertain game and all investors should follow their instincts and best practices.\"]]}}",
|
||||
"__typename": "QuestionNode"
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
177
leetcode-cn/originData/find-the-value-of-the-partition.json
Normal file
177
leetcode-cn/originData/find-the-value-of-the-partition.json
Normal file
File diff suppressed because one or more lines are too long
177
leetcode-cn/originData/painting-the-walls.json
Normal file
177
leetcode-cn/originData/painting-the-walls.json
Normal file
File diff suppressed because one or more lines are too long
189
leetcode-cn/originData/special-permutations.json
Normal file
189
leetcode-cn/originData/special-permutations.json
Normal file
File diff suppressed because one or more lines are too long
176
leetcode-cn/originData/total-distance-traveled.json
Normal file
176
leetcode-cn/originData/total-distance-traveled.json
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,36 @@
|
||||
<p>卡车有两个油箱。给你两个整数,<code>mainTank</code> 表示主油箱中的燃料(以升为单位),<code>additionalTank</code> 表示副油箱中的燃料(以升为单位)。</p>
|
||||
|
||||
<p>该卡车每耗费 <code>1</code> 升燃料都可以行驶 <code>10</code> km。每当主油箱使用了 <code>5</code> 升燃料时,如果副油箱至少有 <code>1</code> 升燃料,则会将 <code>1</code> 升燃料从副油箱转移到主油箱。</p>
|
||||
|
||||
<p>返回卡车可以行驶的最大距离。</p>
|
||||
|
||||
<p>注意:从副油箱向主油箱注入燃料不是连续行为。这一事件会在每消耗 <code>5</code> 升燃料时突然且立即发生。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>mainTank = 5, additionalTank = 10
|
||||
<strong>输出:</strong>60
|
||||
<strong>解释:</strong>
|
||||
在用掉 5 升燃料后,主油箱中燃料还剩下 (5 - 5 + 1) = 1 升,行驶距离为 50km 。
|
||||
在用掉剩下的 1 升燃料后,没有新的燃料注入到主油箱中,主油箱变为空。
|
||||
总行驶距离为 60km 。
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>mainTank = 1, additionalTank = 2
|
||||
<strong>输出:</strong>10
|
||||
<strong>解释:</strong>
|
||||
在用掉 1 升燃料后,主油箱变为空。
|
||||
总行驶距离为 10km 。
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= mainTank, additionalTank <= 100</code></li>
|
||||
</ul>
|
@ -0,0 +1,48 @@
|
||||
<p>给你一个 <strong>正</strong> 整数数组 <code>nums</code> 。</p>
|
||||
|
||||
<p>将 <code>nums</code> 分成两个数组:<code>nums1</code> 和 <code>nums2</code> ,并满足下述条件:</p>
|
||||
|
||||
<ul>
|
||||
<li>数组 <code>nums</code> 中的每个元素都属于数组 <code>nums1</code> 或数组 <code>nums2</code> 。</li>
|
||||
<li>两个数组都 <strong>非空</strong> 。</li>
|
||||
<li>分区值 <strong>最小</strong> 。</li>
|
||||
</ul>
|
||||
|
||||
<p>分区值的计算方法是 <code>|max(nums1) - min(nums2)|</code> 。</p>
|
||||
|
||||
<p>其中,<code>max(nums1)</code> 表示数组 <code>nums1</code> 中的最大元素,<code>min(nums2)</code> 表示数组 <code>nums2</code> 中的最小元素。</p>
|
||||
|
||||
<p>返回表示分区值的整数。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>nums = [1,3,2,4]
|
||||
<strong>输出:</strong>1
|
||||
<strong>解释:</strong>可以将数组 nums 分成 nums1 = [1,2] 和 nums2 = [3,4] 。
|
||||
- 数组 nums1 的最大值等于 2 。
|
||||
- 数组 nums2 的最小值等于 3 。
|
||||
分区值等于 |2 - 3| = 1 。
|
||||
可以证明 1 是所有分区方案的最小值。
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>nums = [100,1,10]
|
||||
<strong>输出:</strong>9
|
||||
<strong>解释:</strong>可以将数组 nums 分成 nums1 = [10] 和 nums2 = [100,1] 。
|
||||
- 数组 nums1 的最大值等于 10 。
|
||||
- 数组 nums2 的最小值等于 1 。
|
||||
分区值等于 |10 - 1| = 9 。
|
||||
可以证明 9 是所有分区方案的最小值。
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>2 <= nums.length <= 10<sup>5</sup></code></li>
|
||||
<li><code>1 <= nums[i] <= 10<sup>9</sup></code></li>
|
||||
</ul>
|
@ -0,0 +1,32 @@
|
||||
<p>给你一个下标从 <strong>0</strong> 开始的整数数组 <code>nums</code> ,它包含 <code>n</code> 个 <strong>互不相同</strong> 的正整数。如果 <code>nums</code> 的一个排列满足以下条件,我们称它是一个特别的排列:</p>
|
||||
|
||||
<ul>
|
||||
<li>对于 <code>0 <= i < n - 1</code> 的下标 <code>i</code> ,要么 <code>nums[i] % nums[i+1] == 0</code> ,要么 <code>nums[i+1] % nums[i] == 0</code> 。</li>
|
||||
</ul>
|
||||
|
||||
<p>请你返回特别排列的总数目,由于答案可能很大,请将它对<strong> </strong><code>10<sup>9 </sup>+ 7</code> <strong>取余</strong> 后返回。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre><strong>输入:</strong>nums = [2,3,6]
|
||||
<b>输出:</b>2
|
||||
<b>解释:</b>[3,6,2] 和 [2,6,3] 是 nums 两个特别的排列。
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre><b>输入:</b>nums = [1,4,3]
|
||||
<b>输出:</b>2
|
||||
<b>解释:</b>[3,1,4] 和 [4,1,3] 是 nums 两个特别的排列。
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>2 <= nums.length <= 14</code></li>
|
||||
<li><code>1 <= nums[i] <= 10<sup>9</sup></code></li>
|
||||
</ul>
|
@ -0,0 +1,35 @@
|
||||
<p>给你两个长度为 <code>n</code> 下标从 <strong>0</strong> 开始的整数数组 <code>cost</code> 和 <code>time</code> ,分别表示给 <code>n</code> 堵不同的墙刷油漆需要的开销和时间。你有两名油漆匠:</p>
|
||||
|
||||
<ul>
|
||||
<li>一位需要 <strong>付费</strong> 的油漆匠,刷第 <code>i</code> 堵墙需要花费 <code>time[i]</code> 单位的时间,开销为 <code>cost[i]</code> 单位的钱。</li>
|
||||
<li>一位 <strong>免费</strong> 的油漆匠,刷 <strong>任意</strong> 一堵墙的时间为 <code>1</code> 单位,开销为 <code>0</code> 。但是必须在付费油漆匠 <strong>工作</strong> 时,免费油漆匠才会工作。</li>
|
||||
</ul>
|
||||
|
||||
<p>请你返回刷完 <code>n</code> 堵墙最少开销为多少。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre><b>输入:</b>cost = [1,2,3,2], time = [1,2,3,2]
|
||||
<b>输出:</b>3
|
||||
<strong>解释:</strong>下标为 0 和 1 的墙由付费油漆匠来刷,需要 3 单位时间。同时,免费油漆匠刷下标为 2 和 3 的墙,需要 2 单位时间,开销为 0 。总开销为 1 + 2 = 3 。
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre><b>输入:</b>cost = [2,3,4,2], time = [1,1,1,1]
|
||||
<b>输出:</b>4
|
||||
<b>解释:</b>下标为 0 和 3 的墙由付费油漆匠来刷,需要 2 单位时间。同时,免费油漆匠刷下标为 1 和 2 的墙,需要 2 单位时间,开销为 0 。总开销为 2 + 2 = 4 。
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= cost.length <= 500</code></li>
|
||||
<li><code>cost.length == time.length</code></li>
|
||||
<li><code>1 <= cost[i] <= 10<sup>6</sup></code></li>
|
||||
<li><code>1 <= time[i] <= 500</code></li>
|
||||
</ul>
|
@ -0,0 +1,37 @@
|
||||
<p>A truck has two fuel tanks. You are given two integers, <code>mainTank</code> representing the fuel present in the main tank in liters and <code>additionalTank</code> representing the fuel present in the additional tank in liters.</p>
|
||||
|
||||
<p>The truck has a mileage of <code>10</code> km per liter. Whenever <code>5</code> liters of fuel get used up in the main tank, if the additional tank has at least <code>1</code> liters of fuel, <code>1</code> liters of fuel will be transferred from the additional tank to the main tank.</p>
|
||||
|
||||
<p>Return <em>the maximum distance which can be traveled.</em></p>
|
||||
|
||||
<p><strong>Note: </strong>Injection from the additional tank is not continuous. It happens suddenly and immediately for every 5 liters consumed.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> mainTank = 5, additionalTank = 10
|
||||
<strong>Output:</strong> 60
|
||||
<strong>Explanation:</strong>
|
||||
After spending 5 litre of fuel, fuel remaining is (5 - 5 + 1) = 1 litre and distance traveled is 50km.
|
||||
After spending another 1 litre of fuel, no fuel gets injected in the main tank and the main tank becomes empty.
|
||||
Total distance traveled is 60km.
|
||||
</pre>
|
||||
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> mainTank = 1, additionalTank = 2
|
||||
<strong>Output:</strong> 10
|
||||
<strong>Explanation:</strong>
|
||||
After spending 1 litre of fuel, the main tank becomes empty.
|
||||
Total distance traveled is 10km.
|
||||
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= mainTank, additionalTank <= 100</code></li>
|
||||
</ul>
|
@ -0,0 +1,48 @@
|
||||
<p>You are given a <strong>positive</strong> integer array <code>nums</code>.</p>
|
||||
|
||||
<p>Partition <code>nums</code> into two arrays, <code>nums1</code> and <code>nums2</code>, such that:</p>
|
||||
|
||||
<ul>
|
||||
<li>Each element of the array <code>nums</code> belongs to either the array <code>nums1</code> or the array <code>nums2</code>.</li>
|
||||
<li>Both arrays are <strong>non-empty</strong>.</li>
|
||||
<li>The value of the partition is <strong>minimized</strong>.</li>
|
||||
</ul>
|
||||
|
||||
<p>The value of the partition is <code>|max(nums1) - min(nums2)|</code>.</p>
|
||||
|
||||
<p>Here, <code>max(nums1)</code> denotes the maximum element of the array <code>nums1</code>, and <code>min(nums2)</code> denotes the minimum element of the array <code>nums2</code>.</p>
|
||||
|
||||
<p>Return <em>the integer denoting the value of such partition</em>.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> nums = [1,3,2,4]
|
||||
<strong>Output:</strong> 1
|
||||
<strong>Explanation:</strong> We can partition the array nums into nums1 = [1,2] and nums2 = [3,4].
|
||||
- The maximum element of the array nums1 is equal to 2.
|
||||
- The minimum element of the array nums2 is equal to 3.
|
||||
The value of the partition is |2 - 3| = 1.
|
||||
It can be proven that 1 is the minimum value out of all partitions.
|
||||
</pre>
|
||||
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> nums = [100,1,10]
|
||||
<strong>Output:</strong> 9
|
||||
<strong>Explanation:</strong> We can partition the array nums into nums1 = [10] and nums2 = [100,1].
|
||||
- The maximum element of the array nums1 is equal to 10.
|
||||
- The minimum element of the array nums2 is equal to 1.
|
||||
The value of the partition is |10 - 1| = 9.
|
||||
It can be proven that 9 is the minimum value out of all partitions.
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>2 <= nums.length <= 10<sup>5</sup></code></li>
|
||||
<li><code>1 <= nums[i] <= 10<sup>9</sup></code></li>
|
||||
</ul>
|
@ -0,0 +1,32 @@
|
||||
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> containing <code>n</code> <strong>distinct</strong> positive integers. A permutation of <code>nums</code> is called special if:</p>
|
||||
|
||||
<ul>
|
||||
<li>For all indexes <code>0 <= i < n - 1</code>, either <code>nums[i] % nums[i+1] == 0</code> or <code>nums[i+1] % nums[i] == 0</code>.</li>
|
||||
</ul>
|
||||
|
||||
<p>Return <em>the total number of special permutations. </em>As the answer could be large, return it <strong>modulo </strong><code>10<sup>9 </sup>+ 7</code>.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> nums = [2,3,6]
|
||||
<strong>Output:</strong> 2
|
||||
<strong>Explanation:</strong> [3,6,2] and [2,6,3] are the two special permutations of nums.
|
||||
</pre>
|
||||
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> nums = [1,4,3]
|
||||
<strong>Output:</strong> 2
|
||||
<strong>Explanation:</strong> [3,1,4] and [4,1,3] are the two special permutations of nums.
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>2 <= nums.length <= 14</code></li>
|
||||
<li><code>1 <= nums[i] <= 10<sup>9</sup></code></li>
|
||||
</ul>
|
@ -0,0 +1,35 @@
|
||||
<p>You are given two <strong>0-indexed</strong> integer arrays, <code>cost</code> and <code>time</code>, of size <code>n</code> representing the costs and the time taken to paint <code>n</code> different walls respectively. There are two painters available:</p>
|
||||
|
||||
<ul>
|
||||
<li>A<strong> paid painter</strong> that paints the <code>i<sup>th</sup></code> wall in <code>time[i]</code> units of time and takes <code>cost[i]</code> units of money.</li>
|
||||
<li>A<strong> free painter</strong> that paints <strong>any</strong> wall in <code>1</code> unit of time at a cost of <code>0</code>. But the free painter can only be used if the paid painter is already <strong>occupied</strong>.</li>
|
||||
</ul>
|
||||
|
||||
<p>Return <em>the minimum amount of money required to paint the </em><code>n</code><em> walls.</em></p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> cost = [1,2,3,2], time = [1,2,3,2]
|
||||
<strong>Output:</strong> 3
|
||||
<strong>Explanation:</strong> The walls at index 0 and 1 will be painted by the paid painter, and it will take 3 units of time; meanwhile, the free painter will paint the walls at index 2 and 3, free of cost in 2 units of time. Thus, the total cost is 1 + 2 = 3.
|
||||
</pre>
|
||||
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> cost = [2,3,4,2], time = [1,1,1,1]
|
||||
<strong>Output:</strong> 4
|
||||
<strong>Explanation:</strong> The walls at index 0 and 3 will be painted by the paid painter, and it will take 2 units of time; meanwhile, the free painter will paint the walls at index 1 and 2, free of cost in 2 units of time. Thus, the total cost is 2 + 2 = 4.
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= cost.length <= 500</code></li>
|
||||
<li><code>cost.length == time.length</code></li>
|
||||
<li><code>1 <= cost[i] <= 10<sup>6</sup></code></li>
|
||||
<li><code>1 <= time[i] <= 500</code></li>
|
||||
</ul>
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,56 @@
|
||||
{
|
||||
"data": {
|
||||
"question": {
|
||||
"questionId": "2885",
|
||||
"questionFrontendId": "2738",
|
||||
"boundTopicId": null,
|
||||
"title": "Count Occurrences in Text",
|
||||
"titleSlug": "count-occurrences-in-text",
|
||||
"content": null,
|
||||
"translatedTitle": null,
|
||||
"translatedContent": null,
|
||||
"isPaidOnly": true,
|
||||
"difficulty": "Medium",
|
||||
"likes": 4,
|
||||
"dislikes": 5,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
"exampleTestcases": null,
|
||||
"categoryTitle": "Database",
|
||||
"contributors": [],
|
||||
"topicTags": [
|
||||
{
|
||||
"name": "Database",
|
||||
"slug": "database",
|
||||
"translatedName": null,
|
||||
"__typename": "TopicTagNode"
|
||||
}
|
||||
],
|
||||
"companyTagStats": null,
|
||||
"codeSnippets": null,
|
||||
"stats": "{\"totalAccepted\": \"90\", \"totalSubmission\": \"230\", \"totalAcceptedRaw\": 90, \"totalSubmissionRaw\": 230, \"acRate\": \"39.1%\"}",
|
||||
"hints": [],
|
||||
"solution": null,
|
||||
"status": null,
|
||||
"sampleTestCase": "{\"headers\":{\"Files\":[\"file_name\",\"content\"]},\"rows\":{\"Files\":[[\"draft1.txt\",\"The stock exchange predicts a bull market which would make many investors happy.\"],[\"draft2.txt\",\"The stock exchange predicts a bull market which would make many investors happy, but analysts warn of possibility of too much optimism and that in fact we are awaiting a bear market.\"],[\"final.txt\",\"The stock exchange predicts a bull market which would make many investors happy, but analysts warn of possibility of too much optimism and that in fact we are awaiting a bear market. As always predicting the future market is an uncertain game and all investors should follow their instincts and best practices.\"]]}}",
|
||||
"metaData": "{\n \"mysql\": [\n \"Create table If Not Exists Files (file_name varchar(100), content text )\"\n ],\n \"mssql\": [\n \"Create table Files (file_name varchar(100), content text )\"\n ],\n \"oraclesql\": [\n \"Create table Files (file_name varchar(100), content clob )\"\n ],\n \"database\": true\n}",
|
||||
"judgerAvailable": true,
|
||||
"judgeType": "large",
|
||||
"mysqlSchemas": [
|
||||
"Create table If Not Exists Files (file_name varchar(100), content text )",
|
||||
"Truncate table Files",
|
||||
"insert into Files (file_name, content) values ('draft1.txt', 'The stock exchange predicts a bull market which would make many investors happy.')",
|
||||
"insert into Files (file_name, content) values ('draft2.txt', 'The stock exchange predicts a bull market which would make many investors happy, but analysts warn of possibility of too much optimism and that in fact we are awaiting a bear market.')",
|
||||
"insert into Files (file_name, content) values ('final.txt', 'The stock exchange predicts a bull market which would make many investors happy, but analysts warn of possibility of too much optimism and that in fact we are awaiting a bear market. As always predicting the future market is an uncertain game and all investors should follow their instincts and best practices.')"
|
||||
],
|
||||
"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
174
leetcode/originData/find-the-value-of-the-partition.json
Normal file
174
leetcode/originData/find-the-value-of-the-partition.json
Normal file
File diff suppressed because one or more lines are too long
174
leetcode/originData/painting-the-walls.json
Normal file
174
leetcode/originData/painting-the-walls.json
Normal file
File diff suppressed because one or more lines are too long
186
leetcode/originData/special-permutations.json
Normal file
186
leetcode/originData/special-permutations.json
Normal file
File diff suppressed because one or more lines are too long
173
leetcode/originData/total-distance-traveled.json
Normal file
173
leetcode/originData/total-distance-traveled.json
Normal file
File diff suppressed because one or more lines are too long
48
leetcode/problem/find-the-value-of-the-partition.html
Normal file
48
leetcode/problem/find-the-value-of-the-partition.html
Normal file
@ -0,0 +1,48 @@
|
||||
<p>You are given a <strong>positive</strong> integer array <code>nums</code>.</p>
|
||||
|
||||
<p>Partition <code>nums</code> into two arrays, <code>nums1</code> and <code>nums2</code>, such that:</p>
|
||||
|
||||
<ul>
|
||||
<li>Each element of the array <code>nums</code> belongs to either the array <code>nums1</code> or the array <code>nums2</code>.</li>
|
||||
<li>Both arrays are <strong>non-empty</strong>.</li>
|
||||
<li>The value of the partition is <strong>minimized</strong>.</li>
|
||||
</ul>
|
||||
|
||||
<p>The value of the partition is <code>|max(nums1) - min(nums2)|</code>.</p>
|
||||
|
||||
<p>Here, <code>max(nums1)</code> denotes the maximum element of the array <code>nums1</code>, and <code>min(nums2)</code> denotes the minimum element of the array <code>nums2</code>.</p>
|
||||
|
||||
<p>Return <em>the integer denoting the value of such partition</em>.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> nums = [1,3,2,4]
|
||||
<strong>Output:</strong> 1
|
||||
<strong>Explanation:</strong> We can partition the array nums into nums1 = [1,2] and nums2 = [3,4].
|
||||
- The maximum element of the array nums1 is equal to 2.
|
||||
- The minimum element of the array nums2 is equal to 3.
|
||||
The value of the partition is |2 - 3| = 1.
|
||||
It can be proven that 1 is the minimum value out of all partitions.
|
||||
</pre>
|
||||
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> nums = [100,1,10]
|
||||
<strong>Output:</strong> 9
|
||||
<strong>Explanation:</strong> We can partition the array nums into nums1 = [10] and nums2 = [100,1].
|
||||
- The maximum element of the array nums1 is equal to 10.
|
||||
- The minimum element of the array nums2 is equal to 1.
|
||||
The value of the partition is |10 - 1| = 9.
|
||||
It can be proven that 9 is the minimum value out of all partitions.
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>2 <= nums.length <= 10<sup>5</sup></code></li>
|
||||
<li><code>1 <= nums[i] <= 10<sup>9</sup></code></li>
|
||||
</ul>
|
35
leetcode/problem/painting-the-walls.html
Normal file
35
leetcode/problem/painting-the-walls.html
Normal file
@ -0,0 +1,35 @@
|
||||
<p>You are given two <strong>0-indexed</strong> integer arrays, <code>cost</code> and <code>time</code>, of size <code>n</code> representing the costs and the time taken to paint <code>n</code> different walls respectively. There are two painters available:</p>
|
||||
|
||||
<ul>
|
||||
<li>A<strong> paid painter</strong> that paints the <code>i<sup>th</sup></code> wall in <code>time[i]</code> units of time and takes <code>cost[i]</code> units of money.</li>
|
||||
<li>A<strong> free painter</strong> that paints <strong>any</strong> wall in <code>1</code> unit of time at a cost of <code>0</code>. But the free painter can only be used if the paid painter is already <strong>occupied</strong>.</li>
|
||||
</ul>
|
||||
|
||||
<p>Return <em>the minimum amount of money required to paint the </em><code>n</code><em> walls.</em></p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> cost = [1,2,3,2], time = [1,2,3,2]
|
||||
<strong>Output:</strong> 3
|
||||
<strong>Explanation:</strong> The walls at index 0 and 1 will be painted by the paid painter, and it will take 3 units of time; meanwhile, the free painter will paint the walls at index 2 and 3, free of cost in 2 units of time. Thus, the total cost is 1 + 2 = 3.
|
||||
</pre>
|
||||
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> cost = [2,3,4,2], time = [1,1,1,1]
|
||||
<strong>Output:</strong> 4
|
||||
<strong>Explanation:</strong> The walls at index 0 and 3 will be painted by the paid painter, and it will take 2 units of time; meanwhile, the free painter will paint the walls at index 1 and 2, free of cost in 2 units of time. Thus, the total cost is 2 + 2 = 4.
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= cost.length <= 500</code></li>
|
||||
<li><code>cost.length == time.length</code></li>
|
||||
<li><code>1 <= cost[i] <= 10<sup>6</sup></code></li>
|
||||
<li><code>1 <= time[i] <= 500</code></li>
|
||||
</ul>
|
32
leetcode/problem/special-permutations.html
Normal file
32
leetcode/problem/special-permutations.html
Normal file
@ -0,0 +1,32 @@
|
||||
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> containing <code>n</code> <strong>distinct</strong> positive integers. A permutation of <code>nums</code> is called special if:</p>
|
||||
|
||||
<ul>
|
||||
<li>For all indexes <code>0 <= i < n - 1</code>, either <code>nums[i] % nums[i+1] == 0</code> or <code>nums[i+1] % nums[i] == 0</code>.</li>
|
||||
</ul>
|
||||
|
||||
<p>Return <em>the total number of special permutations. </em>As the answer could be large, return it <strong>modulo </strong><code>10<sup>9 </sup>+ 7</code>.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> nums = [2,3,6]
|
||||
<strong>Output:</strong> 2
|
||||
<strong>Explanation:</strong> [3,6,2] and [2,6,3] are the two special permutations of nums.
|
||||
</pre>
|
||||
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> nums = [1,4,3]
|
||||
<strong>Output:</strong> 2
|
||||
<strong>Explanation:</strong> [3,1,4] and [4,1,3] are the two special permutations of nums.
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>2 <= nums.length <= 14</code></li>
|
||||
<li><code>1 <= nums[i] <= 10<sup>9</sup></code></li>
|
||||
</ul>
|
37
leetcode/problem/total-distance-traveled.html
Normal file
37
leetcode/problem/total-distance-traveled.html
Normal file
@ -0,0 +1,37 @@
|
||||
<p>A truck has two fuel tanks. You are given two integers, <code>mainTank</code> representing the fuel present in the main tank in liters and <code>additionalTank</code> representing the fuel present in the additional tank in liters.</p>
|
||||
|
||||
<p>The truck has a mileage of <code>10</code> km per liter. Whenever <code>5</code> liters of fuel get used up in the main tank, if the additional tank has at least <code>1</code> liters of fuel, <code>1</code> liters of fuel will be transferred from the additional tank to the main tank.</p>
|
||||
|
||||
<p>Return <em>the maximum distance which can be traveled.</em></p>
|
||||
|
||||
<p><strong>Note: </strong>Injection from the additional tank is not continuous. It happens suddenly and immediately for every 5 liters consumed.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> mainTank = 5, additionalTank = 10
|
||||
<strong>Output:</strong> 60
|
||||
<strong>Explanation:</strong>
|
||||
After spending 5 litre of fuel, fuel remaining is (5 - 5 + 1) = 1 litre and distance traveled is 50km.
|
||||
After spending another 1 litre of fuel, no fuel gets injected in the main tank and the main tank becomes empty.
|
||||
Total distance traveled is 60km.
|
||||
</pre>
|
||||
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> mainTank = 1, additionalTank = 2
|
||||
<strong>Output:</strong> 10
|
||||
<strong>Explanation:</strong>
|
||||
After spending 1 litre of fuel, the main tank becomes empty.
|
||||
Total distance traveled is 10km.
|
||||
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= mainTank, additionalTank <= 100</code></li>
|
||||
</ul>
|
Loading…
Reference in New Issue
Block a user