1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-19 20:16:48 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-06-18 16:20:32 +08:00
parent 6ba311f0f3
commit 8891b38740
50 changed files with 16483 additions and 11625 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
{
"data": {
"question": {
"questionId": "2441",
"questionFrontendId": "2308",
"boundTopicId": null,
"title": "Arrange Table by Gender",
"titleSlug": "arrange-table-by-gender",
"content": null,
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": true,
"difficulty": "Medium",
"likes": 7,
"dislikes": 4,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": null,
"categoryTitle": "Database",
"contributors": [],
"topicTags": [],
"companyTagStats": null,
"codeSnippets": null,
"stats": "{\"totalAccepted\": \"123\", \"totalSubmission\": \"162\", \"totalAcceptedRaw\": 123, \"totalSubmissionRaw\": 162, \"acRate\": \"75.9%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\": {\"Genders\": [\"user_id\", \"gender\"]}, \"rows\": {\"Genders\": [[4, \"male\"], [7, \"female\"], [2, \"other\"], [5, \"male\"], [3, \"female\"], [8, \"male\"], [6, \"other\"], [1, \"other\"], [9, \"female\"]]}}",
"metaData": "{\n \"mysql\": [\n \"Create table If Not Exists Genders (user_id int, gender ENUM('female', 'other', 'male'))\"\n ],\n \"mssql\": [\n \"Create table Genders (user_id int, gender VARCHAR(6) NOT NULL CHECK (gender IN ('female', 'other', 'male')))\"\n ],\n \"oraclesql\": [\n \"Create table Genders (user_id int, gender VARCHAR(6) NOT NULL CHECK (gender IN ('female', 'other', 'male')))\"\n ],\n \"database\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"Create table If Not Exists Genders (user_id int, gender ENUM('female', 'other', 'male'))",
"Truncate table Genders",
"insert into Genders (user_id, gender) values ('4', 'male')",
"insert into Genders (user_id, gender) values ('7', 'female')",
"insert into Genders (user_id, gender) values ('2', 'other')",
"insert into Genders (user_id, gender) values ('5', 'male')",
"insert into Genders (user_id, gender) values ('3', 'female')",
"insert into Genders (user_id, gender) values ('8', 'male')",
"insert into Genders (user_id, gender) values ('6', 'other')",
"insert into Genders (user_id, gender) values ('1', 'other')",
"insert into Genders (user_id, gender) values ('9', 'female')"
],
"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

View File

@@ -0,0 +1,59 @@
{
"data": {
"question": {
"questionId": "2440",
"questionFrontendId": "2298",
"boundTopicId": null,
"title": "Tasks Count in the Weekend",
"titleSlug": "tasks-count-in-the-weekend",
"content": null,
"translatedTitle": null,
"translatedContent": null,
"isPaidOnly": true,
"difficulty": "Medium",
"likes": 6,
"dislikes": 2,
"isLiked": null,
"similarQuestions": "[]",
"exampleTestcases": null,
"categoryTitle": "Database",
"contributors": [],
"topicTags": [
{
"name": "Database",
"slug": "database",
"translatedName": null,
"__typename": "TopicTagNode"
}
],
"companyTagStats": null,
"codeSnippets": null,
"stats": "{\"totalAccepted\": \"255\", \"totalSubmission\": \"314\", \"totalAcceptedRaw\": 255, \"totalSubmissionRaw\": 314, \"acRate\": \"81.2%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\": {\"Tasks\": [\"task_id\", \"assignee_id\", \"submit_date\"]}, \"rows\": {\"Tasks\": [[1, 1, \"2022-06-13\"], [2, 6, \"2022-06-14\"], [3, 6, \"2022-06-15\"], [4, 3, \"2022-06-18\"], [5, 5, \"2022-06-19\"], [6, 7, \"2022-06-19\"]]}}",
"metaData": "{\n \"mysql\": [\n \"Create table If Not Exists Tasks (task_id int, assignee_id int, submit_date date)\"\n ],\n \"mssql\": [\n \"Create table Tasks (task_id int, assignee_id int, submit_date date)\"\n ],\n \"oraclesql\": [\n \"Create table Tasks (task_id int, assignee_id int, submit_date date)\",\n \"ALTER SESSION SET nls_date_format='YYYY-MM-DD'\"\n ],\n \"database\": true\n}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"Create table If Not Exists Tasks (task_id int, assignee_id int, submit_date date)",
"Truncate table Tasks",
"insert into Tasks (task_id, assignee_id, submit_date) values ('1', '1', '2022-06-13')",
"insert into Tasks (task_id, assignee_id, submit_date) values ('2', '6', '2022-06-14')",
"insert into Tasks (task_id, assignee_id, submit_date) values ('3', '6', '2022-06-15')",
"insert into Tasks (task_id, assignee_id, submit_date) values ('4', '3', '2022-06-18')",
"insert into Tasks (task_id, assignee_id, submit_date) values ('5', '5', '2022-06-19')",
"insert into Tasks (task_id, assignee_id, submit_date) values ('6', '7', '2022-06-19')"
],
"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

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,57 @@
<p>You are given a <strong>0-indexed</strong> 2D integer array <code>brackets</code> where <code>brackets[i] = [upper<sub>i</sub>, percent<sub>i</sub>]</code> means that the <code>i<sup>th</sup></code> tax bracket has an upper bound of <code>upper<sub>i</sub></code> and is taxed at a rate of <code>percent<sub>i</sub></code>. The brackets are <strong>sorted</strong> by upper bound (i.e. <code>upper<sub>i-1</sub> &lt; upper<sub>i</sub></code> for <code>0 &lt; i &lt; brackets.length</code>).</p>
<p>Tax is calculated as follows:</p>
<ul>
<li>The first <code>upper<sub>0</sub></code> dollars earned are taxed at a rate of <code>percent<sub>0</sub></code>.</li>
<li>The next <code>upper<sub>1</sub> - upper<sub>0</sub></code> dollars earned are taxed at a rate of <code>percent<sub>1</sub></code>.</li>
<li>The next <code>upper<sub>2</sub> - upper<sub>1</sub></code> dollars earned are taxed at a rate of <code>percent<sub>2</sub></code>.</li>
<li>And so on.</li>
</ul>
<p>You are given an integer <code>income</code> representing the amount of money you earned. Return <em>the amount of money that you have to pay in taxes.</em> Answers within <code>10<sup>-5</sup></code> of the actual answer will be accepted.</p>
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> brackets = [[3,50],[7,10],[12,25]], income = 10
<strong>Output:</strong> 2.65000
<strong>Explanation:</strong>
Based on your income, you have 3 dollars in the 1<sup>st</sup> tax bracket, 4 dollars in the 2<sup>nd</sup> tax bracket, and 3 dollars in the 3<sup>rd</sup> tax bracket.
The tax rate for the three tax brackets is 50%, 10%, and 25%, respectively.
In total, you pay $3 * 50% + $4 * 10% + $3 * 25% = $2.65 in taxes.
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> brackets = [[1,0],[4,25],[5,50]], income = 2
<strong>Output:</strong> 0.25000
<strong>Explanation:</strong>
Based on your income, you have 1 dollar in the 1<sup>st</sup> tax bracket and 1 dollar in the 2<sup>nd</sup> tax bracket.
The tax rate for the two tax brackets is 0% and 25%, respectively.
In total, you pay $1 * 0% + $1 * 25% = $0.25 in taxes.
</pre>
<p><strong>Example 3:</strong></p>
<pre>
<strong>Input:</strong> brackets = [[2,50]], income = 0
<strong>Output:</strong> 0.00000
<strong>Explanation:</strong>
You have no income to tax, so you have to pay a total of $0 in taxes.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= brackets.length &lt;= 100</code></li>
<li><code>1 &lt;= upper<sub>i</sub> &lt;= 1000</code></li>
<li><code>0 &lt;= percent<sub>i</sub> &lt;= 100</code></li>
<li><code>0 &lt;= income &lt;= 1000</code></li>
<li><code>upper<sub>i</sub></code> is sorted in ascending order.</li>
<li>All the values of <code>upper<sub>i</sub></code> are <strong>unique</strong>.</li>
<li>The upper bound of the last tax bracket is greater than or equal to <code>income</code>.</li>
</ul>

View File

@@ -0,0 +1,45 @@
<p>The <strong>score</strong> of an array is defined as the <strong>product</strong> of its sum and its length.</p>
<ul>
<li>For example, the score of <code>[1, 2, 3, 4, 5]</code> is <code>(1 + 2 + 3 + 4 + 5) * 5 = 75</code>.</li>
</ul>
<p>Given a positive integer array <code>nums</code> and an integer <code>k</code>, return <em>the <strong>number of non-empty subarrays</strong> of</em> <code>nums</code> <em>whose score is <strong>strictly less</strong> than</em> <code>k</code>.</p>
<p>A <strong>subarray</strong> is a contiguous sequence of elements within an array.</p>
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> nums = [2,1,4,3,5], k = 10
<strong>Output:</strong> 6
<strong>Explanation:</strong>
The 6 subarrays having scores less than 10 are:
- [2] with score 2 * 1 = 2.
- [1] with score 1 * 1 = 1.
- [4] with score 4 * 1 = 4.
- [3] with score 3 * 1 = 3.
- [5] with score 5 * 1 = 5.
- [2,1] with score (2 + 1) * 2 = 6.
Note that subarrays such as [1,4] and [4,3,5] are not considered because their scores are 10 and 36 respectively, while we need scores strictly less than 10.</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> nums = [1,1,1], k = 5
<strong>Output:</strong> 5
<strong>Explanation:</strong>
Every subarray except [1,1,1] has a score less than 5.
[1,1,1] has a score (1 + 1 + 1) * 3 = 9, which is greater than 5.
Thus, there are 5 subarrays having scores less than 5.
</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>5</sup></code></li>
<li><code>1 &lt;= k &lt;= 10<sup>15</sup></code></li>
</ul>

View File

@@ -0,0 +1,40 @@
<p>You are given an integer array <code>cookies</code>, where <code>cookies[i]</code> denotes the number of cookies in the <code>i<sup>th</sup></code> bag. You are also given an integer <code>k</code> that denotes the number of children to distribute <strong>all</strong> the bags of cookies to. All the cookies in the same bag must go to the same child and cannot be split up.</p>
<p>The <strong>unfairness</strong> of a distribution is defined as the <strong>maximum</strong> <strong>total</strong> cookies obtained by a single child in the distribution.</p>
<p>Return <em>the <strong>minimum</strong> unfairness of all distributions</em>.</p>
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> cookies = [8,15,10,20,8], k = 2
<strong>Output:</strong> 31
<strong>Explanation:</strong> One optimal distribution is [8,15,8] and [10,20]
- The 1<sup>st</sup> child receives [8,15,8] which has a total of 8 + 15 + 8 = 31 cookies.
- The 2<sup>nd</sup> child receives [10,20] which has a total of 10 + 20 = 30 cookies.
The unfairness of the distribution is max(31,30) = 31.
It can be shown that there is no distribution with an unfairness less than 31.
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> cookies = [6,1,3,2,2,4,1,2], k = 3
<strong>Output:</strong> 7
<strong>Explanation:</strong> One optimal distribution is [6,1], [3,2,2], and [4,1,2]
- The 1<sup>st</sup> child receives [6,1] which has a total of 6 + 1 = 7 cookies.
- The 2<sup>nd</sup> child receives [3,2,2] which has a total of 3 + 2 + 2 = 7 cookies.
- The 3<sup>rd</sup> child receives [4,1,2] which has a total of 4 + 1 + 2 = 7 cookies.
The unfairness of the distribution is max(7,7,7) = 7.
It can be shown that there is no distribution with an unfairness less than 7.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>2 &lt;= cookies.length &lt;= 8</code></li>
<li><code>1 &lt;= cookies[i] &lt;= 10<sup>5</sup></code></li>
<li><code>2 &lt;= k &lt;= cookies.length</code></li>
</ul>

View File

@@ -0,0 +1,45 @@
<p>You are given two strings <code>s</code> and <code>sub</code>. You are also given a 2D character array <code>mappings</code> where <code>mappings[i] = [old<sub>i</sub>, new<sub>i</sub>]</code> indicates that you may <strong>replace</strong> any number of <code>old<sub>i</sub></code> characters of <code>sub</code> with <code>new<sub>i</sub></code>. Each character in <code>sub</code> <strong>cannot</strong> be replaced more than once.</p>
<p>Return <code>true</code><em> if it is possible to make </em><code>sub</code><em> a substring of </em><code>s</code><em> by replacing zero or more characters according to </em><code>mappings</code>. Otherwise, return <code>false</code>.</p>
<p>A <strong>substring</strong> is a contiguous non-empty sequence of characters within a string.</p>
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> s = &quot;fool3e7bar&quot;, sub = &quot;leet&quot;, mappings = [[&quot;e&quot;,&quot;3&quot;],[&quot;t&quot;,&quot;7&quot;],[&quot;t&quot;,&quot;8&quot;]]
<strong>Output:</strong> true
<strong>Explanation:</strong> Replace the first &#39;e&#39; in sub with &#39;3&#39; and &#39;t&#39; in sub with &#39;7&#39;.
Now sub = &quot;l3e7&quot; is a substring of s, so we return true.</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> s = &quot;fooleetbar&quot;, sub = &quot;f00l&quot;, mappings = [[&quot;o&quot;,&quot;0&quot;]]
<strong>Output:</strong> false
<strong>Explanation:</strong> The string &quot;f00l&quot; is not a substring of s and no replacements can be made.
Note that we cannot replace &#39;0&#39; with &#39;o&#39;.
</pre>
<p><strong>Example 3:</strong></p>
<pre>
<strong>Input:</strong> s = &quot;Fool33tbaR&quot;, sub = &quot;leetd&quot;, mappings = [[&quot;e&quot;,&quot;3&quot;],[&quot;t&quot;,&quot;7&quot;],[&quot;t&quot;,&quot;8&quot;],[&quot;d&quot;,&quot;b&quot;],[&quot;p&quot;,&quot;b&quot;]]
<strong>Output:</strong> true
<strong>Explanation:</strong> Replace the first and second &#39;e&#39; in sub with &#39;3&#39; and &#39;d&#39; in sub with &#39;b&#39;.
Now sub = &quot;l33tb&quot; is a substring of s, so we return true.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= sub.length &lt;= s.length &lt;= 5000</code></li>
<li><code>0 &lt;= mappings.length &lt;= 1000</code></li>
<li><code>mappings[i].length == 2</code></li>
<li><code>old<sub>i</sub> != new<sub>i</sub></code></li>
<li><code>s</code> and <code>sub</code> consist of uppercase and lowercase English letters and digits.</li>
<li><code>old<sub>i</sub></code> and <code>new<sub>i</sub></code> are either uppercase or lowercase English letters or digits.</li>
</ul>

View File

@@ -0,0 +1,42 @@
<p>You are given a <strong>0-indexed</strong> <code>m x n</code> integer matrix <code>grid</code> consisting of <strong>distinct</strong> integers from <code>0</code> to <code>m * n - 1</code>. You can move in this matrix from a cell to any other cell in the <strong>next</strong> row. That is, if you are in cell <code>(x, y)</code> such that <code>x &lt; m - 1</code>, you can move to any of the cells <code>(x + 1, 0)</code>, <code>(x + 1, 1)</code>, ..., <code>(x + 1, n - 1)</code>. <strong>Note</strong> that it is not possible to move from cells in the last row.</p>
<p>Each possible move has a cost given by a <strong>0-indexed</strong> 2D array <code>moveCost</code> of size <code>(m * n) x n</code>, where <code>moveCost[i][j]</code> is the cost of moving from a cell with value <code>i</code> to a cell in column <code>j</code> of the next row. The cost of moving from cells in the last row of <code>grid</code> can be ignored.</p>
<p>The cost of a path in <code>grid</code> is the <strong>sum</strong> of all values of cells visited plus the <strong>sum</strong> of costs of all the moves made. Return <em>the <strong>minimum</strong> cost of a path that starts from any cell in the <strong>first</strong> row and ends at any cell in the <strong>last</strong> row.</em></p>
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2022/04/28/griddrawio-2.png" style="width: 301px; height: 281px;" />
<pre>
<strong>Input:</strong> grid = [[5,3],[4,0],[2,1]], moveCost = [[9,8],[1,5],[10,12],[18,6],[2,4],[14,3]]
<strong>Output:</strong> 17
<strong>Explanation: </strong>The path with the minimum possible cost is the path 5 -&gt; 0 -&gt; 1.
- The sum of the values of cells visited is 5 + 0 + 1 = 6.
- The cost of moving from 5 to 0 is 3.
- The cost of moving from 0 to 1 is 8.
So the total cost of the path is 6 + 3 + 8 = 17.
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> grid = [[5,1,2],[4,0,3]], moveCost = [[12,10,15],[20,23,8],[21,7,1],[8,1,13],[9,10,25],[5,3,2]]
<strong>Output:</strong> 6
<strong>Explanation:</strong> The path with the minimum possible cost is the path 2 -&gt; 3.
- The sum of the values of cells visited is 2 + 3 = 5.
- The cost of moving from 2 to 3 is 1.
So the total cost of this path is 5 + 1 = 6.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>m == grid.length</code></li>
<li><code>n == grid[i].length</code></li>
<li><code>2 &lt;= m, n &lt;= 50</code></li>
<li><code>grid</code> consists of distinct integers from <code>0</code> to <code>m * n - 1</code>.</li>
<li><code>moveCost.length == m * n</code></li>
<li><code>moveCost[i].length == n</code></li>
<li><code>1 &lt;= moveCost[i][j] &lt;= 100</code></li>
</ul>

View File

@@ -0,0 +1,49 @@
<p>You are given an array of strings <code>ideas</code> that represents a list of names to be used in the process of naming a company. The process of naming a company is as follows:</p>
<ol>
<li>Choose 2 <strong>distinct</strong> names from <code>ideas</code>, call them <code>idea<sub>A</sub></code> and <code>idea<sub>B</sub></code>.</li>
<li>Swap the first letters of <code>idea<sub>A</sub></code> and <code>idea<sub>B</sub></code> with each other.</li>
<li>If <strong>both</strong> of the new names are not found in the original <code>ideas</code>, then the name <code>idea<sub>A</sub> idea<sub>B</sub></code> (the <strong>concatenation</strong> of <code>idea<sub>A</sub></code> and <code>idea<sub>B</sub></code>, separated by a space) is a valid company name.</li>
<li>Otherwise, it is not a valid name.</li>
</ol>
<p>Return <em>the number of <strong>distinct</strong> valid names for the company</em>.</p>
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> ideas = [&quot;coffee&quot;,&quot;donuts&quot;,&quot;time&quot;,&quot;toffee&quot;]
<strong>Output:</strong> 6
<strong>Explanation:</strong> The following selections are valid:
- (&quot;coffee&quot;, &quot;donuts&quot;): The company name created is &quot;doffee conuts&quot;.
- (&quot;donuts&quot;, &quot;coffee&quot;): The company name created is &quot;conuts doffee&quot;.
- (&quot;donuts&quot;, &quot;time&quot;): The company name created is &quot;tonuts dime&quot;.
- (&quot;donuts&quot;, &quot;toffee&quot;): The company name created is &quot;tonuts doffee&quot;.
- (&quot;time&quot;, &quot;donuts&quot;): The company name created is &quot;dime tonuts&quot;.
- (&quot;toffee&quot;, &quot;donuts&quot;): The company name created is &quot;doffee tonuts&quot;.
Therefore, there are a total of 6 distinct company names.
The following are some examples of invalid selections:
- (&quot;coffee&quot;, &quot;time&quot;): The name &quot;toffee&quot; formed after swapping already exists in the original array.
- (&quot;time&quot;, &quot;toffee&quot;): Both names are still the same after swapping and exist in the original array.
- (&quot;coffee&quot;, &quot;toffee&quot;): Both names formed after swapping already exist in the original array.
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> ideas = [&quot;lack&quot;,&quot;back&quot;]
<strong>Output:</strong> 0
<strong>Explanation:</strong> There are no valid selections. Therefore, 0 is returned.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>2 &lt;= ideas.length &lt;= 5 * 10<sup>4</sup></code></li>
<li><code>1 &lt;= ideas[i].length &lt;= 10</code></li>
<li><code>ideas[i]</code> consists of lowercase English letters.</li>
<li>All the strings in <code>ideas</code> are <strong>unique</strong>.</li>
</ul>

View File

@@ -0,0 +1,44 @@
<p>A password is said to be <strong>strong</strong> if it satisfies all the following criteria:</p>
<ul>
<li>It has at least <code>8</code> characters.</li>
<li>It contains at least <strong>one lowercase</strong> letter.</li>
<li>It contains at least <strong>one uppercase</strong> letter.</li>
<li>It contains at least <strong>one digit</strong>.</li>
<li>It contains at least <strong>one special character</strong>. The special characters are the characters in the following string: <code>&quot;!@#$%^&amp;*()-+&quot;</code>.</li>
<li>It does <strong>not</strong> contain <code>2</code> of the same character in adjacent positions (i.e., <code>&quot;aab&quot;</code> violates this condition, but <code>&quot;aba&quot;</code> does not).</li>
</ul>
<p>Given a string <code>password</code>, return <code>true</code><em> if it is a <strong>strong</strong> password</em>. Otherwise, return <code>false</code>.</p>
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> password = &quot;IloveLe3tcode!&quot;
<strong>Output:</strong> true
<strong>Explanation:</strong> The password meets all the requirements. Therefore, we return true.
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> password = &quot;Me+You--IsMyDream&quot;
<strong>Output:</strong> false
<strong>Explanation:</strong> The password does not contain a digit and also contains 2 of the same character in adjacent positions. Therefore, we return false.
</pre>
<p><strong>Example 3:</strong></p>
<pre>
<strong>Input:</strong> password = &quot;1aB!&quot;
<strong>Output:</strong> false
<strong>Explanation:</strong> The password does not meet the length requirement. Therefore, we return false.</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 &lt;= password.length &lt;= 100</code></li>
<li><code>password</code> consists of letters, digits, and special characters: <code>&quot;!@#$%^&amp;*()-+&quot;</code>.</li>
</ul>

View File

@@ -0,0 +1,41 @@
<p>You are given two positive integer arrays <code>spells</code> and <code>potions</code>, of length <code>n</code> and <code>m</code> respectively, where <code>spells[i]</code> represents the strength of the <code>i<sup>th</sup></code> spell and <code>potions[j]</code> represents the strength of the <code>j<sup>th</sup></code> potion.</p>
<p>You are also given an integer <code>success</code>. A spell and potion pair is considered <strong>successful</strong> if the <strong>product</strong> of their strengths is <strong>at least</strong> <code>success</code>.</p>
<p>Return <em>an integer array </em><code>pairs</code><em> of length </em><code>n</code><em> where </em><code>pairs[i]</code><em> is the number of <strong>potions</strong> that will form a successful pair with the </em><code>i<sup>th</sup></code><em> spell.</em></p>
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<pre>
<strong>Input:</strong> spells = [5,1,3], potions = [1,2,3,4,5], success = 7
<strong>Output:</strong> [4,0,3]
<strong>Explanation:</strong>
- 0<sup>th</sup> spell: 5 * [1,2,3,4,5] = [5,<u><strong>10</strong></u>,<u><strong>15</strong></u>,<u><strong>20</strong></u>,<u><strong>25</strong></u>]. 4 pairs are successful.
- 1<sup>st</sup> spell: 1 * [1,2,3,4,5] = [1,2,3,4,5]. 0 pairs are successful.
- 2<sup>nd</sup> spell: 3 * [1,2,3,4,5] = [3,6,<u><strong>9</strong></u>,<u><strong>12</strong></u>,<u><strong>15</strong></u>]. 3 pairs are successful.
Thus, [4,0,3] is returned.
</pre>
<p><strong>Example 2:</strong></p>
<pre>
<strong>Input:</strong> spells = [3,1,2], potions = [8,5,8], success = 16
<strong>Output:</strong> [2,0,2]
<strong>Explanation:</strong>
- 0<sup>th</sup> spell: 3 * [8,5,8] = [<u><strong>24</strong></u>,15,<u><strong>24</strong></u>]. 2 pairs are successful.
- 1<sup>st</sup> spell: 1 * [8,5,8] = [8,5,8]. 0 pairs are successful.
- 2<sup>nd</sup> spell: 2 * [8,5,8] = [<strong><u>16</u></strong>,10,<u><strong>16</strong></u>]. 2 pairs are successful.
Thus, [2,0,2] is returned.
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>n == spells.length</code></li>
<li><code>m == potions.length</code></li>
<li><code>1 &lt;= n, m &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= spells[i], potions[i] &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= success &lt;= 10<sup>10</sup></code></li>
</ul>